diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6386acf..bd17f562 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up .NET uses: actions/setup-dotnet@v3 @@ -39,7 +39,7 @@ jobs: if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up .NET uses: actions/setup-dotnet@v3 @@ -55,7 +55,7 @@ jobs: runs-on: ${{ github.repository == 'stainless-sdks/orb-csharp' && 'depot-windows-2022' || 'windows-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up .NET uses: actions/setup-dotnet@v5 diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 3d2ac0bd..10f30916 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0" + ".": "0.2.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 96825fac..1f41e32f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 126 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-d45078644e5890989174cc450ad8a814913af66bdb43350b63c1b93b98af9efd.yml -openapi_spec_hash: 9750de93e1e074a3e2e27f115422cb77 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-6017828d1287c194d4d7759dc5b5410225ab58af66ff8605315f70f5e623b82d.yml +openapi_spec_hash: 4390eaf377258fcd7db1dbc073a2c23f config_hash: bcf82bddb691f6be773ac6cae8c03b9a diff --git a/CHANGELOG.md b/CHANGELOG.md index 15283c17..c80ed7a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## 0.2.0 (2026-01-21) + +Full Changelog: [v0.1.0...v0.2.0](https://github.com/orbcorp/orb-csharp/compare/v0.1.0...v0.2.0) + +### Features + +* **api:** api update ([d8f27e8](https://github.com/orbcorp/orb-csharp/commit/d8f27e8e10dc99f7d6e51186171181a05a59547d)) +* **api:** api update ([3bd6cd6](https://github.com/orbcorp/orb-csharp/commit/3bd6cd6413b421ff644eee7f195e6fe0af47c56c)) +* **client:** add `ToString` to `ApiEnum` ([551d3d9](https://github.com/orbcorp/orb-csharp/commit/551d3d983edbc2dd99c0143b2779146fa00ae80f)) +* **client:** add Equals and ToString to params ([8a87021](https://github.com/orbcorp/orb-csharp/commit/8a870218bc1eebf9e4430ed69fedc206e7b9f25c)) + + +### Chores + +* **internal:** codegen related update ([2bc3e43](https://github.com/orbcorp/orb-csharp/commit/2bc3e436b724ff58d3191ea1c4632be595a9e5f5)) +* **internal:** simplify imports ([79d3471](https://github.com/orbcorp/orb-csharp/commit/79d34710f779ca309e84faddc3e28bfa5b9c73bc)) +* **internal:** update `actions/checkout` version ([5849a89](https://github.com/orbcorp/orb-csharp/commit/5849a89be72919068177e2830142c600a0bb7aeb)) + ## 0.1.0 (2026-01-14) Full Changelog: [v0.0.1...v0.1.0](https://github.com/orbcorp/orb-csharp/compare/v0.0.1...v0.1.0) diff --git a/src/Orb.Tests/Models/Alerts/AlertCreateForCustomerParamsTest.cs b/src/Orb.Tests/Models/Alerts/AlertCreateForCustomerParamsTest.cs index de8aebe8..ff402e47 100644 --- a/src/Orb.Tests/Models/Alerts/AlertCreateForCustomerParamsTest.cs +++ b/src/Orb.Tests/Models/Alerts/AlertCreateForCustomerParamsTest.cs @@ -80,6 +80,22 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/alerts/customer_id/customer_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new Alerts::AlertCreateForCustomerParams + { + CustomerID = "customer_id", + Currency = "currency", + Type = Alerts::Type.CreditBalanceDepleted, + Thresholds = [new(0)], + }; + + Alerts::AlertCreateForCustomerParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class TypeTest : TestBase diff --git a/src/Orb.Tests/Models/Alerts/AlertCreateForExternalCustomerParamsTest.cs b/src/Orb.Tests/Models/Alerts/AlertCreateForExternalCustomerParamsTest.cs index 430dc7d5..78f0f872 100644 --- a/src/Orb.Tests/Models/Alerts/AlertCreateForExternalCustomerParamsTest.cs +++ b/src/Orb.Tests/Models/Alerts/AlertCreateForExternalCustomerParamsTest.cs @@ -84,6 +84,22 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new AlertCreateForExternalCustomerParams + { + ExternalCustomerID = "external_customer_id", + Currency = "currency", + Type = AlertCreateForExternalCustomerParamsType.CreditBalanceDepleted, + Thresholds = [new(0)], + }; + + AlertCreateForExternalCustomerParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class AlertCreateForExternalCustomerParamsTypeTest : TestBase diff --git a/src/Orb.Tests/Models/Alerts/AlertCreateForSubscriptionParamsTest.cs b/src/Orb.Tests/Models/Alerts/AlertCreateForSubscriptionParamsTest.cs index 2ebc435f..a65c6152 100644 --- a/src/Orb.Tests/Models/Alerts/AlertCreateForSubscriptionParamsTest.cs +++ b/src/Orb.Tests/Models/Alerts/AlertCreateForSubscriptionParamsTest.cs @@ -83,6 +83,22 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new AlertCreateForSubscriptionParams + { + SubscriptionID = "subscription_id", + Thresholds = [new(0)], + Type = AlertCreateForSubscriptionParamsType.UsageExceeded, + MetricID = "metric_id", + }; + + AlertCreateForSubscriptionParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class AlertCreateForSubscriptionParamsTypeTest : TestBase diff --git a/src/Orb.Tests/Models/Alerts/AlertDisableParamsTest.cs b/src/Orb.Tests/Models/Alerts/AlertDisableParamsTest.cs index c17bac78..f62600f9 100644 --- a/src/Orb.Tests/Models/Alerts/AlertDisableParamsTest.cs +++ b/src/Orb.Tests/Models/Alerts/AlertDisableParamsTest.cs @@ -62,4 +62,18 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new AlertDisableParams + { + AlertConfigurationID = "alert_configuration_id", + SubscriptionID = "subscription_id", + }; + + AlertDisableParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Alerts/AlertEnableParamsTest.cs b/src/Orb.Tests/Models/Alerts/AlertEnableParamsTest.cs index ce7dad90..83486a8f 100644 --- a/src/Orb.Tests/Models/Alerts/AlertEnableParamsTest.cs +++ b/src/Orb.Tests/Models/Alerts/AlertEnableParamsTest.cs @@ -62,4 +62,18 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new AlertEnableParams + { + AlertConfigurationID = "alert_configuration_id", + SubscriptionID = "subscription_id", + }; + + AlertEnableParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Alerts/AlertListParamsTest.cs b/src/Orb.Tests/Models/Alerts/AlertListParamsTest.cs index c5fba882..a3f33cdb 100644 --- a/src/Orb.Tests/Models/Alerts/AlertListParamsTest.cs +++ b/src/Orb.Tests/Models/Alerts/AlertListParamsTest.cs @@ -166,4 +166,25 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new AlertListParams + { + CreatedAtGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAtGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAtLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAtLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Cursor = "cursor", + CustomerID = "customer_id", + ExternalCustomerID = "external_customer_id", + Limit = 1, + SubscriptionID = "subscription_id", + }; + + AlertListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Alerts/AlertRetrieveParamsTest.cs b/src/Orb.Tests/Models/Alerts/AlertRetrieveParamsTest.cs index 1f4af2e6..a0f19075 100644 --- a/src/Orb.Tests/Models/Alerts/AlertRetrieveParamsTest.cs +++ b/src/Orb.Tests/Models/Alerts/AlertRetrieveParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/alerts/alert_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new AlertRetrieveParams { AlertID = "alert_id" }; + + AlertRetrieveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Alerts/AlertUpdateParamsTest.cs b/src/Orb.Tests/Models/Alerts/AlertUpdateParamsTest.cs index dd2c0ffb..1184a225 100644 --- a/src/Orb.Tests/Models/Alerts/AlertUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Alerts/AlertUpdateParamsTest.cs @@ -39,4 +39,18 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/alerts/alert_configuration_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new AlertUpdateParams + { + AlertConfigurationID = "alert_configuration_id", + Thresholds = [new(0)], + }; + + AlertUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs b/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs index 06be5d09..7cad1873 100644 --- a/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs +++ b/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs @@ -528,6 +528,219 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/plans/plan_id/versions"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BetaCreatePlanVersionParams + { + PlanID = "plan_id", + Version = 0, + AddAdjustments = + [ + new() + { + Adjustment = new Models::NewPercentageDiscount() + { + AdjustmentType = + Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewPercentageDiscountFilterField.PriceID, + Operator = Models::NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::NewPercentageDiscountPriceType.Usage, + }, + PlanPhaseOrder = 0, + }, + ], + AddPrices = + [ + new() + { + AllocationPrice = new() + { + Amount = "10.00", + Cadence = Models::Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = Models::CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = Models::NewAllocationPriceFilterField.ItemID, + Operator = Models::NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + PlanPhaseOrder = 0, + Price = new Models::NewPlanUnitPrice() + { + Cadence = Models::NewPlanUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + }, + ], + RemoveAdjustments = [new() { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }], + RemovePrices = [new() { PriceID = "price_id", PlanPhaseOrder = 0 }], + ReplaceAdjustments = + [ + new() + { + Adjustment = new Models::NewPercentageDiscount() + { + AdjustmentType = + Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewPercentageDiscountFilterField.PriceID, + Operator = Models::NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + PlanPhaseOrder = 0, + }, + ], + ReplacePrices = + [ + new() + { + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() + { + Amount = "10.00", + Cadence = Models::Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = Models::CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = Models::NewAllocationPriceFilterField.ItemID, + Operator = Models::NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + PlanPhaseOrder = 0, + Price = new Models::NewPlanUnitPrice() + { + Cadence = Models::NewPlanUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + }, + ], + SetAsDefault = true, + }; + + BetaCreatePlanVersionParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class AddAdjustmentTest : TestBase @@ -3074,49 +3287,6 @@ public void CumulativeGroupedAllocationValidationWorks() value.Validate(); } - [Fact] - public void MinimumValidationWorks() - { - Price value = new Minimum() - { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - [Fact] public void NewPlanMinimumCompositeValidationWorks() { @@ -4785,13 +4955,14 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void MinimumSerializationRoundtripWorks() + public void NewPlanMinimumCompositeSerializationRoundtripWorks() { - Price value = new Minimum() + Price value = new Models::NewPlanMinimumCompositePrice() { - Cadence = MinimumCadence.Annual, + Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4831,54 +5002,7 @@ public void MinimumSerializationRoundtripWorks() } [Fact] - public void NewPlanMinimumCompositeSerializationRoundtripWorks() - { - Price value = new Models::NewPlanMinimumCompositePrice() - { - Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, - ItemID = "item_id", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void PercentSerializationRoundtripWorks() + public void PercentSerializationRoundtripWorks() { Price value = new Percent() { @@ -8189,17 +8313,17 @@ public void TieredSerializationRoundtripWorks() } } -public class MinimumTest : TestBase +public class PercentTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Minimum + var model = new Percent { - Cadence = MinimumCadence.Annual, + Cadence = PercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8232,15 +8356,11 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = MinimumCadence.Annual; + ApiEnum expectedCadence = PercentCadence.Annual; string expectedItemID = "item_id"; - MinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); string expectedName = "Annual fee"; + PercentConfig expectedPercentConfig = new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -8249,7 +8369,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - MinimumConversionRateConfig expectedConversionRateConfig = + PercentConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8275,9 +8395,9 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedCadence, model.Cadence); Assert.Equal(expectedItemID, model.ItemID); - Assert.Equal(expectedMinimumConfig, model.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedPercentConfig, model.PercentConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -8303,12 +8423,12 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Minimum + var model = new Percent { - Cadence = MinimumCadence.Annual, + Cadence = PercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8342,7 +8462,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); Assert.Equal(model, deserialized); } @@ -8350,12 +8470,12 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Minimum + var model = new Percent { - Cadence = MinimumCadence.Annual, + Cadence = PercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8389,21 +8509,17 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = MinimumCadence.Annual; + ApiEnum expectedCadence = PercentCadence.Annual; string expectedItemID = "item_id"; - MinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); string expectedName = "Annual fee"; + PercentConfig expectedPercentConfig = new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -8412,7 +8528,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - MinimumConversionRateConfig expectedConversionRateConfig = + PercentConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8438,9 +8554,9 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedCadence, deserialized.Cadence); Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.Equal(expectedMinimumConfig, deserialized.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedPercentConfig, deserialized.PercentConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -8469,12 +8585,12 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Minimum + var model = new Percent { - Cadence = MinimumCadence.Annual, + Cadence = PercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8513,12 +8629,12 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Minimum + var model = new Percent { - Cadence = MinimumCadence.Annual, + Cadence = PercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), }; Assert.Null(model.BillableMetricID); @@ -8552,12 +8668,12 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Minimum + var model = new Percent { - Cadence = MinimumCadence.Annual, + Cadence = PercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), }; model.Validate(); @@ -8566,12 +8682,12 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Minimum + var model = new Percent { - Cadence = MinimumCadence.Annual, + Cadence = PercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -8619,12 +8735,12 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Minimum + var model = new Percent { - Cadence = MinimumCadence.Annual, + Cadence = PercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -8645,26 +8761,26 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class MinimumCadenceTest : TestBase +public class PercentCadenceTest : TestBase { [Theory] - [InlineData(MinimumCadence.Annual)] - [InlineData(MinimumCadence.SemiAnnual)] - [InlineData(MinimumCadence.Monthly)] - [InlineData(MinimumCadence.Quarterly)] - [InlineData(MinimumCadence.OneTime)] - [InlineData(MinimumCadence.Custom)] - public void Validation_Works(MinimumCadence rawValue) + [InlineData(PercentCadence.Annual)] + [InlineData(PercentCadence.SemiAnnual)] + [InlineData(PercentCadence.Monthly)] + [InlineData(PercentCadence.Quarterly)] + [InlineData(PercentCadence.OneTime)] + [InlineData(PercentCadence.Custom)] + public void Validation_Works(PercentCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -8674,19 +8790,19 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(MinimumCadence.Annual)] - [InlineData(MinimumCadence.SemiAnnual)] - [InlineData(MinimumCadence.Monthly)] - [InlineData(MinimumCadence.Quarterly)] - [InlineData(MinimumCadence.OneTime)] - [InlineData(MinimumCadence.Custom)] - public void SerializationRoundtrip_Works(MinimumCadence rawValue) + [InlineData(PercentCadence.Annual)] + [InlineData(PercentCadence.SemiAnnual)] + [InlineData(PercentCadence.Monthly)] + [InlineData(PercentCadence.Quarterly)] + [InlineData(PercentCadence.OneTime)] + [InlineData(PercentCadence.Custom)] + public void SerializationRoundtrip_Works(PercentCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( json, ModelBase.SerializerOptions ); @@ -8697,12 +8813,12 @@ public void SerializationRoundtrip_Works(MinimumCadence rawValue) [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( json, ModelBase.SerializerOptions ); @@ -8711,27 +8827,25 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class MinimumConfigTest : TestBase +public class PercentConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new PercentConfig { Percent = 0 }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + double expectedPercent = 0; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedPercent, model.Percent); } [Fact] public void SerializationRoundtrip_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new PercentConfig { Percent = 0 }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -8742,83 +8856,35 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new PercentConfig { Percent = 0 }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + double expectedPercent = 0; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedPercent, deserialized.Percent); } [Fact] public void Validation_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() - { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() - { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() - { - var model = new MinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() - { - var model = new MinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; + var model = new PercentConfig { Percent = 0 }; model.Validate(); } } -public class MinimumConversionRateConfigTest : TestBase +public class PercentConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + PercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -8829,7 +8895,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + PercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -8849,13 +8915,13 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + PercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8866,7 +8932,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + PercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -8881,7 +8947,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8890,17 +8956,22 @@ public void TieredSerializationRoundtripWorks() } } -public class PercentTest : TestBase +public class EventOutputTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Percent + var model = new EventOutput { - Cadence = PercentCadence.Annual, + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8933,11 +9004,16 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = PercentCadence.Annual; + ApiEnum expectedCadence = EventOutputCadence.Annual; + EventOutputConfig expectedEventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); string expectedName = "Annual fee"; - PercentConfig expectedPercentConfig = new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -8946,7 +9022,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PercentConversionRateConfig expectedConversionRateConfig = + EventOutputConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8971,10 +9047,10 @@ public void FieldRoundtrip_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedEventOutputConfig, model.EventOutputConfig); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedPercentConfig, model.PercentConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -9000,12 +9076,17 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Percent + var model = new EventOutput { - Cadence = PercentCadence.Annual, + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9039,7 +9120,10 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -9047,12 +9131,17 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Percent + var model = new EventOutput { - Cadence = PercentCadence.Annual, + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9086,17 +9175,22 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = PercentCadence.Annual; + ApiEnum expectedCadence = EventOutputCadence.Annual; + EventOutputConfig expectedEventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); string expectedName = "Annual fee"; - PercentConfig expectedPercentConfig = new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -9105,7 +9199,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PercentConversionRateConfig expectedConversionRateConfig = + EventOutputConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9130,10 +9224,10 @@ public void FieldRoundtripThroughSerialization_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedEventOutputConfig, deserialized.EventOutputConfig); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedPercentConfig, deserialized.PercentConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -9162,12 +9256,17 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Percent + var model = new EventOutput { - Cadence = PercentCadence.Annual, + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9206,12 +9305,17 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Percent + var model = new EventOutput { - Cadence = PercentCadence.Annual, + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), }; Assert.Null(model.BillableMetricID); @@ -9245,12 +9349,17 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Percent + var model = new EventOutput { - Cadence = PercentCadence.Annual, + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), }; model.Validate(); @@ -9259,12 +9368,17 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Percent + var model = new EventOutput { - Cadence = PercentCadence.Annual, + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -9312,12 +9426,17 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Percent + var model = new EventOutput { - Cadence = PercentCadence.Annual, + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -9338,26 +9457,26 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class PercentCadenceTest : TestBase +public class EventOutputCadenceTest : TestBase { [Theory] - [InlineData(PercentCadence.Annual)] - [InlineData(PercentCadence.SemiAnnual)] - [InlineData(PercentCadence.Monthly)] - [InlineData(PercentCadence.Quarterly)] - [InlineData(PercentCadence.OneTime)] - [InlineData(PercentCadence.Custom)] - public void Validation_Works(PercentCadence rawValue) + [InlineData(EventOutputCadence.Annual)] + [InlineData(EventOutputCadence.SemiAnnual)] + [InlineData(EventOutputCadence.Monthly)] + [InlineData(EventOutputCadence.Quarterly)] + [InlineData(EventOutputCadence.OneTime)] + [InlineData(EventOutputCadence.Custom)] + public void Validation_Works(EventOutputCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -9367,19 +9486,19 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(PercentCadence.Annual)] - [InlineData(PercentCadence.SemiAnnual)] - [InlineData(PercentCadence.Monthly)] - [InlineData(PercentCadence.Quarterly)] - [InlineData(PercentCadence.OneTime)] - [InlineData(PercentCadence.Custom)] - public void SerializationRoundtrip_Works(PercentCadence rawValue) + [InlineData(EventOutputCadence.Annual)] + [InlineData(EventOutputCadence.SemiAnnual)] + [InlineData(EventOutputCadence.Monthly)] + [InlineData(EventOutputCadence.Quarterly)] + [InlineData(EventOutputCadence.OneTime)] + [InlineData(EventOutputCadence.Custom)] + public void SerializationRoundtrip_Works(EventOutputCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( json, ModelBase.SerializerOptions ); @@ -9390,12 +9509,12 @@ public void SerializationRoundtrip_Works(PercentCadence rawValue) [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( json, ModelBase.SerializerOptions ); @@ -9404,25 +9523,39 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class PercentConfigTest : TestBase +public class EventOutputConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new PercentConfig { Percent = 0 }; + var model = new EventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; - double expectedPercent = 0; + string expectedUnitRatingKey = "x"; + string expectedDefaultUnitRate = "default_unit_rate"; + string expectedGroupingKey = "grouping_key"; - Assert.Equal(expectedPercent, model.Percent); + Assert.Equal(expectedUnitRatingKey, model.UnitRatingKey); + Assert.Equal(expectedDefaultUnitRate, model.DefaultUnitRate); + Assert.Equal(expectedGroupingKey, model.GroupingKey); } [Fact] public void SerializationRoundtrip_Works() { - var model = new PercentConfig { Percent = 0 }; + var model = new EventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -9433,35 +9566,99 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new PercentConfig { Percent = 0 }; + var model = new EventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - double expectedPercent = 0; + string expectedUnitRatingKey = "x"; + string expectedDefaultUnitRate = "default_unit_rate"; + string expectedGroupingKey = "grouping_key"; - Assert.Equal(expectedPercent, deserialized.Percent); + Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); + Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); } [Fact] public void Validation_Works() { - var model = new PercentConfig { Percent = 0 }; + var model = new EventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new EventOutputConfig { UnitRatingKey = "x" }; + + Assert.Null(model.DefaultUnitRate); + Assert.False(model.RawData.ContainsKey("default_unit_rate")); + Assert.Null(model.GroupingKey); + Assert.False(model.RawData.ContainsKey("grouping_key")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new EventOutputConfig { UnitRatingKey = "x" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new EventOutputConfig + { + UnitRatingKey = "x", + + DefaultUnitRate = null, + GroupingKey = null, + }; + + Assert.Null(model.DefaultUnitRate); + Assert.True(model.RawData.ContainsKey("default_unit_rate")); + Assert.Null(model.GroupingKey); + Assert.True(model.RawData.ContainsKey("grouping_key")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new EventOutputConfig + { + UnitRatingKey = "x", + + DefaultUnitRate = null, + GroupingKey = null, + }; model.Validate(); } } -public class PercentConversionRateConfigTest : TestBase +public class EventOutputConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - PercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -9472,7 +9669,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - PercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -9492,13 +9689,13 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - PercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9509,7 +9706,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - PercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -9524,7 +9721,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9533,171 +9730,27 @@ public void TieredSerializationRoundtripWorks() } } -public class EventOutputTest : TestBase +public class RemoveAdjustmentTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new EventOutput - { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; - ApiEnum expectedCadence = EventOutputCadence.Annual; - EventOutputConfig expectedEventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - EventOutputConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedEventOutputConfig, model.EventOutputConfig); - Assert.Equal(expectedItemID, model.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); - Assert.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); + string expectedAdjustmentID = "adjustment_id"; + long expectedPlanPhaseOrder = 0; - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); + Assert.Equal(expectedAdjustmentID, model.AdjustmentID); + Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); } [Fact] public void SerializationRoundtrip_Works() { - var model = new EventOutput - { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -9708,173 +9761,26 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new EventOutput - { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = EventOutputCadence.Annual; - EventOutputConfig expectedEventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - EventOutputConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedEventOutputConfig, deserialized.EventOutputConfig); - Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); + string expectedAdjustmentID = "adjustment_id"; + long expectedPlanPhaseOrder = 0; - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); } [Fact] public void Validation_Works() { - var model = new EventOutput - { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; model.Validate(); } @@ -9882,62 +9788,16 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new EventOutput - { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - }; + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id" }; - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.False(model.RawData.ContainsKey("reference_id")); + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new EventOutput - { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - }; + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id" }; model.Validate(); } @@ -9945,194 +9805,52 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new EventOutput + var model = new RemoveAdjustment { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", + AdjustmentID = "adjustment_id", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + PlanPhaseOrder = null, }; - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.True(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.True(model.RawData.ContainsKey("reference_id")); + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new EventOutput + var model = new RemoveAdjustment { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", + AdjustmentID = "adjustment_id", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + PlanPhaseOrder = null, }; model.Validate(); } } -public class EventOutputCadenceTest : TestBase -{ - [Theory] - [InlineData(EventOutputCadence.Annual)] - [InlineData(EventOutputCadence.SemiAnnual)] - [InlineData(EventOutputCadence.Monthly)] - [InlineData(EventOutputCadence.Quarterly)] - [InlineData(EventOutputCadence.OneTime)] - [InlineData(EventOutputCadence.Custom)] - public void Validation_Works(EventOutputCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(EventOutputCadence.Annual)] - [InlineData(EventOutputCadence.SemiAnnual)] - [InlineData(EventOutputCadence.Monthly)] - [InlineData(EventOutputCadence.Quarterly)] - [InlineData(EventOutputCadence.OneTime)] - [InlineData(EventOutputCadence.Custom)] - public void SerializationRoundtrip_Works(EventOutputCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - -public class EventOutputConfigTest : TestBase +public class RemovePriceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new EventOutputConfig - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; - string expectedUnitRatingKey = "x"; - string expectedDefaultUnitRate = "default_unit_rate"; - string expectedGroupingKey = "grouping_key"; + string expectedPriceID = "price_id"; + long expectedPlanPhaseOrder = 0; - Assert.Equal(expectedUnitRatingKey, model.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, model.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedPriceID, model.PriceID); + Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); } [Fact] public void SerializationRoundtrip_Works() { - var model = new EventOutputConfig - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10143,38 +9861,26 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new EventOutputConfig - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedUnitRatingKey = "x"; - string expectedDefaultUnitRate = "default_unit_rate"; - string expectedGroupingKey = "grouping_key"; + string expectedPriceID = "price_id"; + long expectedPlanPhaseOrder = 0; - Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedPriceID, deserialized.PriceID); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); } [Fact] public void Validation_Works() { - var model = new EventOutputConfig - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; model.Validate(); } @@ -10182,18 +9888,16 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new EventOutputConfig { UnitRatingKey = "x" }; + var model = new RemovePrice { PriceID = "price_id" }; - Assert.Null(model.DefaultUnitRate); - Assert.False(model.RawData.ContainsKey("default_unit_rate")); - Assert.Null(model.GroupingKey); - Assert.False(model.RawData.ContainsKey("grouping_key")); - } + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); + } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new EventOutputConfig { UnitRatingKey = "x" }; + var model = new RemovePrice { PriceID = "price_id" }; model.Validate(); } @@ -10201,133 +9905,121 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new EventOutputConfig + var model = new RemovePrice { - UnitRatingKey = "x", + PriceID = "price_id", - DefaultUnitRate = null, - GroupingKey = null, + PlanPhaseOrder = null, }; - Assert.Null(model.DefaultUnitRate); - Assert.True(model.RawData.ContainsKey("default_unit_rate")); - Assert.Null(model.GroupingKey); - Assert.True(model.RawData.ContainsKey("grouping_key")); + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new EventOutputConfig + var model = new RemovePrice { - UnitRatingKey = "x", + PriceID = "price_id", - DefaultUnitRate = null, - GroupingKey = null, + PlanPhaseOrder = null, }; model.Validate(); } } -public class EventOutputConversionRateConfigTest : TestBase +public class ReplaceAdjustmentTest : TestBase { [Fact] - public void UnitValidationWorks() - { - EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() + public void FieldRoundtrip_Works() { - EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + var model = new ReplaceAdjustment { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( + Adjustment = new Models::NewPercentageDiscount() + { + AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = [ new() { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, + Field = Models::NewPercentageDiscountFilterField.PriceID, + Operator = Models::NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], }, - ] - ), + ], + IsInvoiceLevel = true, + PriceType = Models::NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + PlanPhaseOrder = 0, }; - value.Validate(); - } - [Fact] - public void UnitSerializationRoundtripWorks() - { - EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + ReplaceAdjustmentAdjustment expectedAdjustment = new Models::NewPercentageDiscount() { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewPercentageDiscountFilterField.PriceID, + Operator = Models::NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::NewPercentageDiscountPriceType.Usage, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + string expectedReplacesAdjustmentID = "replaces_adjustment_id"; + long expectedPlanPhaseOrder = 0; - Assert.Equal(value, deserialized); + Assert.Equal(expectedAdjustment, model.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); + Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); } [Fact] - public void TieredSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + var model = new ReplaceAdjustment { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( + Adjustment = new Models::NewPercentageDiscount() + { + AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = [ new() { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, + Field = Models::NewPercentageDiscountFilterField.PriceID, + Operator = Models::NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], }, - ] - ), + ], + IsInvoiceLevel = true, + PriceType = Models::NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + PlanPhaseOrder = 0, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - -public class RemoveAdjustmentTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; - - string expectedAdjustmentID = "adjustment_id"; - long expectedPlanPhaseOrder = 0; - - Assert.Equal(expectedAdjustmentID, model.AdjustmentID); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10338,179 +10030,101 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + var model = new ReplaceAdjustment + { + Adjustment = new Models::NewPercentageDiscount() + { + AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewPercentageDiscountFilterField.PriceID, + Operator = Models::NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + PlanPhaseOrder = 0, + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedAdjustmentID = "adjustment_id"; + ReplaceAdjustmentAdjustment expectedAdjustment = new Models::NewPercentageDiscount() + { + AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewPercentageDiscountFilterField.PriceID, + Operator = Models::NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::NewPercentageDiscountPriceType.Usage, + }; + string expectedReplacesAdjustmentID = "replaces_adjustment_id"; long expectedPlanPhaseOrder = 0; - Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); + Assert.Equal(expectedAdjustment, deserialized.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); } [Fact] public void Validation_Works() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + var model = new ReplaceAdjustment + { + Adjustment = new Models::NewPercentageDiscount() + { + AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewPercentageDiscountFilterField.PriceID, + Operator = Models::NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + PlanPhaseOrder = 0, + }; model.Validate(); } [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id" }; - - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id" }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new RemoveAdjustment - { - AdjustmentID = "adjustment_id", - - PlanPhaseOrder = null, - }; - - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new RemoveAdjustment - { - AdjustmentID = "adjustment_id", - - PlanPhaseOrder = null, - }; - - model.Validate(); - } -} - -public class RemovePriceTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; - - string expectedPriceID = "price_id"; - long expectedPlanPhaseOrder = 0; - - Assert.Equal(expectedPriceID, model.PriceID); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedPriceID = "price_id"; - long expectedPlanPhaseOrder = 0; - - Assert.Equal(expectedPriceID, deserialized.PriceID); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - } - - [Fact] - public void Validation_Works() - { - var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new RemovePrice { PriceID = "price_id" }; - - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new RemovePrice { PriceID = "price_id" }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new RemovePrice - { - PriceID = "price_id", - - PlanPhaseOrder = null, - }; - - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new RemovePrice - { - PriceID = "price_id", - - PlanPhaseOrder = null, - }; - - model.Validate(); - } -} - -public class ReplaceAdjustmentTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() { var model = new ReplaceAdjustment { @@ -10535,39 +10149,14 @@ public void FieldRoundtrip_Works() PriceType = Models::NewPercentageDiscountPriceType.Usage, }, ReplacesAdjustmentID = "replaces_adjustment_id", - PlanPhaseOrder = 0, - }; - - ReplaceAdjustmentAdjustment expectedAdjustment = new Models::NewPercentageDiscount() - { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; - long expectedPlanPhaseOrder = 0; - Assert.Equal(expectedAdjustment, model.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); } [Fact] - public void SerializationRoundtrip_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { var model = new ReplaceAdjustment { @@ -10592,20 +10181,13 @@ public void SerializationRoundtrip_Works() PriceType = Models::NewPercentageDiscountPriceType.Usage, }, ReplacesAdjustmentID = "replaces_adjustment_id", - PlanPhaseOrder = 0, }; - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + model.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = new ReplaceAdjustment { @@ -10630,46 +10212,16 @@ public void FieldRoundtripThroughSerialization_Works() PriceType = Models::NewPercentageDiscountPriceType.Usage, }, ReplacesAdjustmentID = "replaces_adjustment_id", - PlanPhaseOrder = 0, - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - ReplaceAdjustmentAdjustment expectedAdjustment = new Models::NewPercentageDiscount() - { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, + PlanPhaseOrder = null, }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; - long expectedPlanPhaseOrder = 0; - Assert.Equal(expectedAdjustment, deserialized.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); } [Fact] - public void Validation_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = new ReplaceAdjustment { @@ -10694,149 +10246,20 @@ public void Validation_Works() PriceType = Models::NewPercentageDiscountPriceType.Usage, }, ReplacesAdjustmentID = "replaces_adjustment_id", - PlanPhaseOrder = 0, - }; - - model.Validate(); - } - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new ReplaceAdjustment - { - Adjustment = new Models::NewPercentageDiscount() - { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, - }, - ReplacesAdjustmentID = "replaces_adjustment_id", + PlanPhaseOrder = null, }; - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); + model.Validate(); } +} +public class ReplaceAdjustmentAdjustmentTest : TestBase +{ [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void NewPercentageDiscountValidationWorks() { - var model = new ReplaceAdjustment - { - Adjustment = new Models::NewPercentageDiscount() - { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, - }, - ReplacesAdjustmentID = "replaces_adjustment_id", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new ReplaceAdjustment - { - Adjustment = new Models::NewPercentageDiscount() - { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, - }, - ReplacesAdjustmentID = "replaces_adjustment_id", - - PlanPhaseOrder = null, - }; - - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new ReplaceAdjustment - { - Adjustment = new Models::NewPercentageDiscount() - { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, - }, - ReplacesAdjustmentID = "replaces_adjustment_id", - - PlanPhaseOrder = null, - }; - - model.Validate(); - } -} - -public class ReplaceAdjustmentAdjustmentTest : TestBase -{ - [Fact] - public void NewPercentageDiscountValidationWorks() - { - ReplaceAdjustmentAdjustment value = new Models::NewPercentageDiscount() + ReplaceAdjustmentAdjustment value = new Models::NewPercentageDiscount() { AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, PercentageDiscount = 0, @@ -13078,49 +12501,6 @@ public void CumulativeGroupedAllocationValidationWorks() value.Validate(); } - [Fact] - public void MinimumValidationWorks() - { - ReplacePricePrice value = new ReplacePricePriceMinimum() - { - Cadence = ReplacePricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - [Fact] public void NewPlanMinimumCompositeValidationWorks() { @@ -14818,1272 +14198,233 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() } [Fact] - public void CumulativeGroupedAllocationSerializationRoundtripWorks() - { - ReplacePricePrice value = new ReplacePricePriceCumulativeGroupedAllocation() - { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void MinimumSerializationRoundtripWorks() - { - ReplacePricePrice value = new ReplacePricePriceMinimum() - { - Cadence = ReplacePricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewPlanMinimumCompositeSerializationRoundtripWorks() - { - ReplacePricePrice value = new Models::NewPlanMinimumCompositePrice() - { - Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, - ItemID = "item_id", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void PercentSerializationRoundtripWorks() - { - ReplacePricePrice value = new ReplacePricePricePercent() - { - Cadence = ReplacePricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void EventOutputSerializationRoundtripWorks() - { - ReplacePricePrice value = new ReplacePricePriceEventOutput() - { - Cadence = ReplacePricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - -public class ReplacePricePriceBulkWithFiltersTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new ReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - ApiEnum expectedCadence = - ReplacePricePriceBulkWithFiltersCadence.Annual; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedBulkWithFiltersConfig, model.BulkWithFiltersConfig); - Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedItemID, model.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); - Assert.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new ReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new ReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - ApiEnum expectedCadence = - ReplacePricePriceBulkWithFiltersCadence.Annual; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedBulkWithFiltersConfig, deserialized.BulkWithFiltersConfig); - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); - } - - [Fact] - public void Validation_Works() - { - var model = new ReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new ReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - }; - - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.False(model.RawData.ContainsKey("reference_id")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new ReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new ReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; - - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.True(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.True(model.RawData.ContainsKey("reference_id")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new ReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; - - model.Validate(); - } -} - -public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - List expectedFilters = - [ - new() { PropertyKey = "x", PropertyValue = "x" }, - ]; - List expectedTiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ]; - - Assert.Equal(expectedFilters.Count, model.Filters.Count); - for (int i = 0; i < expectedFilters.Count; i++) - { - Assert.Equal(expectedFilters[i], model.Filters[i]); - } - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - List expectedFilters = - [ - new() { PropertyKey = "x", PropertyValue = "x" }, - ]; - List expectedTiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ]; - - Assert.Equal(expectedFilters.Count, deserialized.Filters.Count); - for (int i = 0; i < expectedFilters.Count; i++) - { - Assert.Equal(expectedFilters[i], deserialized.Filters[i]); - } - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); - } - } - - [Fact] - public void Validation_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - model.Validate(); - } -} - -public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - { - PropertyKey = "x", - PropertyValue = "x", - }; - - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; - - Assert.Equal(expectedPropertyKey, model.PropertyKey); - Assert.Equal(expectedPropertyValue, model.PropertyValue); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - { - PropertyKey = "x", - PropertyValue = "x", - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - { - PropertyKey = "x", - PropertyValue = "x", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; - - Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); - Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); - } - - [Fact] - public void Validation_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - { - PropertyKey = "x", - PropertyValue = "x", - }; - - model.Validate(); - } -} - -public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", - }; - - string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; - - Assert.Equal(expectedUnitAmount, model.UnitAmount); - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; - - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - } - - [Fact] - public void Validation_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - }; - - Assert.Null(model.TierLowerBound); - Assert.False(model.RawData.ContainsKey("tier_lower_bound")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - - TierLowerBound = null, - }; - - Assert.Null(model.TierLowerBound); - Assert.True(model.RawData.ContainsKey("tier_lower_bound")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - - TierLowerBound = null, - }; - - model.Validate(); - } -} - -public class ReplacePricePriceBulkWithFiltersCadenceTest : TestBase -{ - [Theory] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Annual)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.SemiAnnual)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Monthly)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Quarterly)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.OneTime)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Custom)] - public void Validation_Works(ReplacePricePriceBulkWithFiltersCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Annual)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.SemiAnnual)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Monthly)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Quarterly)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.OneTime)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Custom)] - public void SerializationRoundtrip_Works(ReplacePricePriceBulkWithFiltersCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } -} - -public class ReplacePricePriceBulkWithFiltersConversionRateConfigTest : TestBase -{ - [Fact] - public void UnitValidationWorks() + public void CumulativeGroupedAllocationSerializationRoundtripWorks() { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = - new Models::SharedUnitConversionRateConfig() + ReplacePricePrice value = new ReplacePricePriceCumulativeGroupedAllocation() + { + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), - }; - value.Validate(); + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void TieredValidationWorks() + public void NewPlanMinimumCompositeSerializationRoundtripWorks() { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = - new Models::SharedTieredConversionRateConfig() + ReplacePricePrice value = new Models::NewPlanMinimumCompositePrice() + { + Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, + ItemID = "item_id", + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void UnitSerializationRoundtripWorks() + public void PercentSerializationRoundtripWorks() { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = - new Models::SharedUnitConversionRateConfig() + ReplacePricePrice value = new ReplacePricePricePercent() + { + Cadence = ReplacePricePricePercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), - }; + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } [Fact] - public void TieredSerializationRoundtripWorks() + public void EventOutputSerializationRoundtripWorks() { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = - new Models::SharedTieredConversionRateConfig() + ReplacePricePrice value = new ReplacePricePriceEventOutput() + { + Cadence = ReplacePricePriceEventOutputCadence.Annual, + EventOutputConfig = new() { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class ReplacePricePriceTieredWithProrationTest : TestBase +public class ReplacePricePriceBulkWithFiltersTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceBulkWithFilters { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16116,13 +14457,20 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - ReplacePricePriceTieredWithProrationCadence.Annual; + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + ApiEnum expectedCadence = + ReplacePricePriceBulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; - ReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = - new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -16131,7 +14479,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16155,11 +14503,11 @@ public void FieldRoundtrip_Works() Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; + Assert.Equal(expectedBulkWithFiltersConfig, model.BulkWithFiltersConfig); Assert.Equal(expectedCadence, model.Cadence); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -16185,14 +14533,20 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceBulkWithFilters { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16226,7 +14580,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -16237,14 +14591,20 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceBulkWithFilters { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16278,19 +14638,26 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = - ReplacePricePriceTieredWithProrationCadence.Annual; + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + ApiEnum expectedCadence = + ReplacePricePriceBulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; - ReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = - new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -16299,7 +14666,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16323,11 +14690,11 @@ public void FieldRoundtripThroughSerialization_Works() Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; + Assert.Equal(expectedBulkWithFiltersConfig, deserialized.BulkWithFiltersConfig); Assert.Equal(expectedCadence, deserialized.Cadence); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -16356,14 +14723,20 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceBulkWithFilters { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16402,14 +14775,20 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceBulkWithFilters { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; Assert.Null(model.BillableMetricID); @@ -16443,14 +14822,20 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceBulkWithFilters { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; model.Validate(); @@ -16459,14 +14844,20 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceBulkWithFilters { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -16512,131 +14903,266 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePricePriceBulkWithFilters + { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } +} + +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + List expectedFilters = + [ + new() { PropertyKey = "x", PropertyValue = "x" }, + ]; + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedFilters.Count, model.Filters.Count); + for (int i = 0; i < expectedFilters.Count; i++) + { + Assert.Equal(expectedFilters[i], model.Filters[i]); + } + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedFilters = + [ + new() { PropertyKey = "x", PropertyValue = "x" }, + ]; + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedFilters.Count, deserialized.Filters.Count); + for (int i = 0; i < expectedFilters.Count; i++) + { + Assert.Equal(expectedFilters[i], deserialized.Filters[i]); + } + Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + } + } + + [Fact] + public void Validation_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }; model.Validate(); } } -public class ReplacePricePriceTieredWithProrationCadenceTest : TestBase +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase { - [Theory] - [InlineData(ReplacePricePriceTieredWithProrationCadence.Annual)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.SemiAnnual)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.Monthly)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.Quarterly)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.OneTime)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.Custom)] - public void Validation_Works(ReplacePricePriceTieredWithProrationCadence rawValue) + [Fact] + public void FieldRoundtrip_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + string expectedPropertyKey = "x"; + string expectedPropertyValue = "x"; + + Assert.Equal(expectedPropertyKey, model.PropertyKey); + Assert.Equal(expectedPropertyValue, model.PropertyValue); } [Fact] - public void InvalidEnumValidationThrows_Works() + public void SerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } - [Theory] - [InlineData(ReplacePricePriceTieredWithProrationCadence.Annual)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.SemiAnnual)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.Monthly)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.Quarterly)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.OneTime)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.Custom)] - public void SerializationRoundtrip_Works(ReplacePricePriceTieredWithProrationCadence rawValue) + [Fact] + public void FieldRoundtripThroughSerialization_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); - Assert.Equal(value, deserialized); + string expectedPropertyKey = "x"; + string expectedPropertyValue = "x"; + + Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); + Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void Validation_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; - Assert.Equal(value, deserialized); + model.Validate(); } } -public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTest : TestBase +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; + string expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); } [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -16647,123 +15173,158 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; + string expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); - } + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); } [Fact] public void Validation_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; model.Validate(); } -} -public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", }; - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + } - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, + }; + + Assert.Null(model.TierLowerBound); + Assert.True(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, + }; + + model.Validate(); + } +} + +public class ReplacePricePriceBulkWithFiltersCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePricePriceBulkWithFiltersCadence.Annual)] + [InlineData(ReplacePricePriceBulkWithFiltersCadence.SemiAnnual)] + [InlineData(ReplacePricePriceBulkWithFiltersCadence.Monthly)] + [InlineData(ReplacePricePriceBulkWithFiltersCadence.Quarterly)] + [InlineData(ReplacePricePriceBulkWithFiltersCadence.OneTime)] + [InlineData(ReplacePricePriceBulkWithFiltersCadence.Custom)] + public void Validation_Works(ReplacePricePriceBulkWithFiltersCadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void InvalidEnumValidationThrows_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - Assert.Equal(model, deserialized); + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); } - [Fact] - public void FieldRoundtripThroughSerialization_Works() + [Theory] + [InlineData(ReplacePricePriceBulkWithFiltersCadence.Annual)] + [InlineData(ReplacePricePriceBulkWithFiltersCadence.SemiAnnual)] + [InlineData(ReplacePricePriceBulkWithFiltersCadence.Monthly)] + [InlineData(ReplacePricePriceBulkWithFiltersCadence.Quarterly)] + [InlineData(ReplacePricePriceBulkWithFiltersCadence.OneTime)] + [InlineData(ReplacePricePriceBulkWithFiltersCadence.Custom)] + public void SerializationRoundtrip_Works(ReplacePricePriceBulkWithFiltersCadence rawValue) { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void InvalidEnumSerializationRoundtrip_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); - model.Validate(); + Assert.Equal(value, deserialized); } } -public class ReplacePricePriceTieredWithProrationConversionRateConfigTest : TestBase +public class ReplacePricePriceBulkWithFiltersConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceBulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16775,7 +15336,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceBulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -16796,7 +15357,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceBulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16804,7 +15365,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16815,7 +15376,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceBulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -16832,7 +15393,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16841,23 +15402,19 @@ public void TieredSerializationRoundtripWorks() } } -public class ReplacePricePriceGroupedWithMinMaxThresholdsTest : TestBase +public class ReplacePricePriceTieredWithProrationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceTieredWithProration { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16890,21 +15447,13 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = - new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + ApiEnum expectedCadence = + ReplacePricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; + ReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -16913,7 +15462,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16938,13 +15487,10 @@ public void FieldRoundtrip_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal( - expectedGroupedWithMinMaxThresholdsConfig, - model.GroupedWithMinMaxThresholdsConfig - ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -16970,18 +15516,14 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceTieredWithProration { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -17015,7 +15557,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -17026,18 +15568,14 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceTieredWithProration { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -17071,27 +15609,19 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = - new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + ApiEnum expectedCadence = + ReplacePricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; + ReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -17100,7 +15630,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17125,13 +15655,10 @@ public void FieldRoundtripThroughSerialization_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal( - expectedGroupedWithMinMaxThresholdsConfig, - deserialized.GroupedWithMinMaxThresholdsConfig - ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -17160,18 +15687,14 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceTieredWithProration { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -17210,18 +15733,14 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceTieredWithProration { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; Assert.Null(model.BillableMetricID); @@ -17255,18 +15774,14 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceTieredWithProration { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; model.Validate(); @@ -17275,18 +15790,14 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceTieredWithProration { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -17332,20 +15843,16 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds - { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePricePriceTieredWithProration + { + Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -17366,19 +15873,19 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest : TestBase +public class ReplacePricePriceTieredWithProrationCadenceTest : TestBase { [Theory] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] - public void Validation_Works(ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue) + [InlineData(ReplacePricePriceTieredWithProrationCadence.Annual)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.SemiAnnual)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.Monthly)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.Quarterly)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.OneTime)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.Custom)] + public void Validation_Works(ReplacePricePriceTieredWithProrationCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -17386,7 +15893,7 @@ public void Validation_Works(ReplacePricePriceGroupedWithMinMaxThresholdsCadence public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -17394,22 +15901,20 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] - public void SerializationRoundtrip_Works( - ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue - ) + [InlineData(ReplacePricePriceTieredWithProrationCadence.Annual)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.SemiAnnual)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.Monthly)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.Quarterly)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.OneTime)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works(ReplacePricePriceTieredWithProrationCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -17419,58 +15924,50 @@ ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest - : TestBase +public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = - new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } } [Fact] public void SerializationRoundtrip_Works() { - var model = - new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -17481,56 +15978,123 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = - new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); - Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); - Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); + Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + } } [Fact] public void Validation_Works() { - var model = - new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; model.Validate(); } } -public class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } +} + +public class ReplacePricePriceTieredWithProrationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17542,7 +16106,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -17563,7 +16127,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17571,7 +16135,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17582,7 +16146,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -17599,7 +16163,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17608,20 +16172,20 @@ public void TieredSerializationRoundtripWorks() } } -public class ReplacePricePriceCumulativeGroupedAllocationTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -17657,19 +16221,19 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + ApiEnum expectedCadence = + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" + "grouped_with_min_max_thresholds" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -17680,7 +16244,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17706,8 +16270,8 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedCadence, model.Cadence); Assert.Equal( - expectedCumulativeGroupedAllocationConfig, - model.CumulativeGroupedAllocationConfig + expectedGroupedWithMinMaxThresholdsConfig, + model.GroupedWithMinMaxThresholdsConfig ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); @@ -17737,15 +16301,15 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -17782,7 +16346,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -17793,15 +16357,15 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -17838,25 +16402,25 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = - ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + ApiEnum expectedCadence = + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" + "grouped_with_min_max_thresholds" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -17867,7 +16431,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17893,8 +16457,8 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedCadence, deserialized.Cadence); Assert.Equal( - expectedCumulativeGroupedAllocationConfig, - deserialized.CumulativeGroupedAllocationConfig + expectedGroupedWithMinMaxThresholdsConfig, + deserialized.GroupedWithMinMaxThresholdsConfig ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); @@ -17927,15 +16491,15 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -17977,15 +16541,15 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -18022,15 +16586,15 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -18042,15 +16606,15 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -18101,15 +16665,15 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -18133,19 +16697,19 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class ReplacePricePriceCumulativeGroupedAllocationCadenceTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest : TestBase { [Theory] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] - public void Validation_Works(ReplacePricePriceCumulativeGroupedAllocationCadence rawValue) + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] + public void Validation_Works(ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -18153,7 +16717,7 @@ public void Validation_Works(ReplacePricePriceCumulativeGroupedAllocationCadence public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -18161,22 +16725,22 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] public void SerializationRoundtrip_Works( - ReplacePricePriceCumulativeGroupedAllocationCadence rawValue + ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -18186,58 +16750,58 @@ ReplacePricePriceCumulativeGroupedAllocationCadence rawValue public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest +public class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedMaximumCharge, model.MaximumCharge); + Assert.Equal(expectedMinimumCharge, model.MinimumCharge); + Assert.Equal(expectedPerUnitRate, model.PerUnitRate); } [Fact] public void SerializationRoundtrip_Works() { var model = - new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18249,55 +16813,55 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); + Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); + Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); } [Fact] public void Validation_Works() { var model = - new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; model.Validate(); } } -public class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18309,7 +16873,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -18330,7 +16894,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18338,7 +16902,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18349,7 +16913,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -18366,7 +16930,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18375,16 +16939,22 @@ public void TieredSerializationRoundtripWorks() } } -public class ReplacePricePriceMinimumTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -18418,15 +16988,20 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - ReplacePricePriceMinimumCadence.Annual; + ApiEnum expectedCadence = + ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - ReplacePricePriceMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -18436,7 +17011,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18461,8 +17036,11 @@ public void FieldRoundtrip_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + model.CumulativeGroupedAllocationConfig + ); Assert.Equal(expectedItemID, model.ItemID); - Assert.Equal(expectedMinimumConfig, model.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -18490,11 +17068,17 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -18529,7 +17113,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18540,11 +17124,17 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -18579,21 +17169,26 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = - ReplacePricePriceMinimumCadence.Annual; + ApiEnum expectedCadence = + ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - ReplacePricePriceMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -18603,7 +17198,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18628,8 +17223,11 @@ public void FieldRoundtripThroughSerialization_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + deserialized.CumulativeGroupedAllocationConfig + ); Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.Equal(expectedMinimumConfig, deserialized.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -18660,11 +17258,17 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -18704,11 +17308,17 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", }; @@ -18743,11 +17353,17 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", }; @@ -18757,11 +17373,17 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = null, @@ -18810,11 +17432,17 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = null, @@ -18836,49 +17464,50 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class ReplacePricePriceMinimumCadenceTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationCadenceTest : TestBase { [Theory] - [InlineData(ReplacePricePriceMinimumCadence.Annual)] - [InlineData(ReplacePricePriceMinimumCadence.SemiAnnual)] - [InlineData(ReplacePricePriceMinimumCadence.Monthly)] - [InlineData(ReplacePricePriceMinimumCadence.Quarterly)] - [InlineData(ReplacePricePriceMinimumCadence.OneTime)] - [InlineData(ReplacePricePriceMinimumCadence.Custom)] - public void Validation_Works(ReplacePricePriceMinimumCadence rawValue) + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] + public void Validation_Works(ReplacePricePriceCumulativeGroupedAllocationCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); Assert.Throws(() => value.Validate()); } [Theory] - [InlineData(ReplacePricePriceMinimumCadence.Annual)] - [InlineData(ReplacePricePriceMinimumCadence.SemiAnnual)] - [InlineData(ReplacePricePriceMinimumCadence.Monthly)] - [InlineData(ReplacePricePriceMinimumCadence.Quarterly)] - [InlineData(ReplacePricePriceMinimumCadence.OneTime)] - [InlineData(ReplacePricePriceMinimumCadence.Custom)] - public void SerializationRoundtrip_Works(ReplacePricePriceMinimumCadence rawValue) + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePricePriceCumulativeGroupedAllocationCadence rawValue + ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -18887,51 +17516,62 @@ public void SerializationRoundtrip_Works(ReplacePricePriceMinimumCadence rawValu [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class ReplacePricePriceMinimumMinimumConfigTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, model.GroupAllocation); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -18939,91 +17579,56 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() - { - var model = new ReplacePricePriceMinimumMinimumConfig { MinimumAmount = "minimum_amount" }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() - { - var model = new ReplacePricePriceMinimumMinimumConfig { MinimumAmount = "minimum_amount" }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() - { - var model = new ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() - { - var model = new ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; + var model = + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; model.Validate(); } } -public class ReplacePricePriceMinimumConversionRateConfigTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19035,7 +17640,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -19056,17 +17661,18 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -19074,7 +17680,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -19090,10 +17696,11 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } diff --git a/src/Orb.Tests/Models/Beta/BetaFetchPlanVersionParamsTest.cs b/src/Orb.Tests/Models/Beta/BetaFetchPlanVersionParamsTest.cs index a403e952..f514a861 100644 --- a/src/Orb.Tests/Models/Beta/BetaFetchPlanVersionParamsTest.cs +++ b/src/Orb.Tests/Models/Beta/BetaFetchPlanVersionParamsTest.cs @@ -26,4 +26,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/plans/plan_id/versions/version"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BetaFetchPlanVersionParams { PlanID = "plan_id", Version = "version" }; + + BetaFetchPlanVersionParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Beta/BetaSetDefaultPlanVersionParamsTest.cs b/src/Orb.Tests/Models/Beta/BetaSetDefaultPlanVersionParamsTest.cs index d612d3e1..50387028 100644 --- a/src/Orb.Tests/Models/Beta/BetaSetDefaultPlanVersionParamsTest.cs +++ b/src/Orb.Tests/Models/Beta/BetaSetDefaultPlanVersionParamsTest.cs @@ -26,4 +26,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/plans/plan_id/set_default_version"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BetaSetDefaultPlanVersionParams { PlanID = "plan_id", Version = 0 }; + + BetaSetDefaultPlanVersionParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs b/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs index 5d60504a..473bc2f8 100644 --- a/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs +++ b/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs @@ -539,6 +539,219 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ExternalPlanIDCreatePlanVersionParams + { + ExternalPlanID = "external_plan_id", + Version = 0, + AddAdjustments = + [ + new() + { + Adjustment = new Models::NewPercentageDiscount() + { + AdjustmentType = + Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewPercentageDiscountFilterField.PriceID, + Operator = Models::NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::NewPercentageDiscountPriceType.Usage, + }, + PlanPhaseOrder = 0, + }, + ], + AddPrices = + [ + new() + { + AllocationPrice = new() + { + Amount = "10.00", + Cadence = Models::Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = Models::CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = Models::NewAllocationPriceFilterField.ItemID, + Operator = Models::NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + PlanPhaseOrder = 0, + Price = new Models::NewPlanUnitPrice() + { + Cadence = Models::NewPlanUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + }, + ], + RemoveAdjustments = [new() { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }], + RemovePrices = [new() { PriceID = "price_id", PlanPhaseOrder = 0 }], + ReplaceAdjustments = + [ + new() + { + Adjustment = new Models::NewPercentageDiscount() + { + AdjustmentType = + Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewPercentageDiscountFilterField.PriceID, + Operator = Models::NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + PlanPhaseOrder = 0, + }, + ], + ReplacePrices = + [ + new() + { + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() + { + Amount = "10.00", + Cadence = Models::Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = Models::CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = Models::NewAllocationPriceFilterField.ItemID, + Operator = Models::NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + PlanPhaseOrder = 0, + Price = new Models::NewPlanUnitPrice() + { + Cadence = Models::NewPlanUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + }, + ], + SetAsDefault = true, + }; + + ExternalPlanIDCreatePlanVersionParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class AddAdjustmentTest : TestBase @@ -3085,49 +3298,6 @@ public void CumulativeGroupedAllocationValidationWorks() value.Validate(); } - [Fact] - public void MinimumValidationWorks() - { - Price value = new Minimum() - { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - [Fact] public void NewPlanMinimumCompositeValidationWorks() { @@ -4796,13 +4966,14 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void MinimumSerializationRoundtripWorks() + public void NewPlanMinimumCompositeSerializationRoundtripWorks() { - Price value = new Minimum() + Price value = new Models::NewPlanMinimumCompositePrice() { - Cadence = MinimumCadence.Annual, + Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4842,54 +5013,7 @@ public void MinimumSerializationRoundtripWorks() } [Fact] - public void NewPlanMinimumCompositeSerializationRoundtripWorks() - { - Price value = new Models::NewPlanMinimumCompositePrice() - { - Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, - ItemID = "item_id", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void PercentSerializationRoundtripWorks() + public void PercentSerializationRoundtripWorks() { Price value = new Percent() { @@ -8200,17 +8324,17 @@ public void TieredSerializationRoundtripWorks() } } -public class MinimumTest : TestBase +public class PercentTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Minimum + var model = new Percent { - Cadence = MinimumCadence.Annual, + Cadence = PercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8243,15 +8367,11 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = MinimumCadence.Annual; + ApiEnum expectedCadence = PercentCadence.Annual; string expectedItemID = "item_id"; - MinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); string expectedName = "Annual fee"; + PercentConfig expectedPercentConfig = new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -8260,7 +8380,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - MinimumConversionRateConfig expectedConversionRateConfig = + PercentConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8286,9 +8406,9 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedCadence, model.Cadence); Assert.Equal(expectedItemID, model.ItemID); - Assert.Equal(expectedMinimumConfig, model.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedPercentConfig, model.PercentConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -8314,12 +8434,12 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Minimum + var model = new Percent { - Cadence = MinimumCadence.Annual, + Cadence = PercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8353,7 +8473,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); Assert.Equal(model, deserialized); } @@ -8361,12 +8481,12 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Minimum + var model = new Percent { - Cadence = MinimumCadence.Annual, + Cadence = PercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8400,21 +8520,17 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = MinimumCadence.Annual; + ApiEnum expectedCadence = PercentCadence.Annual; string expectedItemID = "item_id"; - MinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); string expectedName = "Annual fee"; + PercentConfig expectedPercentConfig = new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -8423,7 +8539,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - MinimumConversionRateConfig expectedConversionRateConfig = + PercentConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8449,9 +8565,9 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedCadence, deserialized.Cadence); Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.Equal(expectedMinimumConfig, deserialized.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedPercentConfig, deserialized.PercentConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -8480,12 +8596,12 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Minimum + var model = new Percent { - Cadence = MinimumCadence.Annual, + Cadence = PercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8524,12 +8640,12 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Minimum + var model = new Percent { - Cadence = MinimumCadence.Annual, + Cadence = PercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), }; Assert.Null(model.BillableMetricID); @@ -8563,12 +8679,12 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Minimum + var model = new Percent { - Cadence = MinimumCadence.Annual, + Cadence = PercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), }; model.Validate(); @@ -8577,12 +8693,12 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Minimum + var model = new Percent { - Cadence = MinimumCadence.Annual, + Cadence = PercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -8630,12 +8746,12 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Minimum + var model = new Percent { - Cadence = MinimumCadence.Annual, + Cadence = PercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -8656,26 +8772,26 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class MinimumCadenceTest : TestBase +public class PercentCadenceTest : TestBase { [Theory] - [InlineData(MinimumCadence.Annual)] - [InlineData(MinimumCadence.SemiAnnual)] - [InlineData(MinimumCadence.Monthly)] - [InlineData(MinimumCadence.Quarterly)] - [InlineData(MinimumCadence.OneTime)] - [InlineData(MinimumCadence.Custom)] - public void Validation_Works(MinimumCadence rawValue) + [InlineData(PercentCadence.Annual)] + [InlineData(PercentCadence.SemiAnnual)] + [InlineData(PercentCadence.Monthly)] + [InlineData(PercentCadence.Quarterly)] + [InlineData(PercentCadence.OneTime)] + [InlineData(PercentCadence.Custom)] + public void Validation_Works(PercentCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -8685,19 +8801,19 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(MinimumCadence.Annual)] - [InlineData(MinimumCadence.SemiAnnual)] - [InlineData(MinimumCadence.Monthly)] - [InlineData(MinimumCadence.Quarterly)] - [InlineData(MinimumCadence.OneTime)] - [InlineData(MinimumCadence.Custom)] - public void SerializationRoundtrip_Works(MinimumCadence rawValue) + [InlineData(PercentCadence.Annual)] + [InlineData(PercentCadence.SemiAnnual)] + [InlineData(PercentCadence.Monthly)] + [InlineData(PercentCadence.Quarterly)] + [InlineData(PercentCadence.OneTime)] + [InlineData(PercentCadence.Custom)] + public void SerializationRoundtrip_Works(PercentCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( json, ModelBase.SerializerOptions ); @@ -8708,12 +8824,12 @@ public void SerializationRoundtrip_Works(MinimumCadence rawValue) [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( json, ModelBase.SerializerOptions ); @@ -8722,27 +8838,25 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class MinimumConfigTest : TestBase +public class PercentConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new PercentConfig { Percent = 0 }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + double expectedPercent = 0; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedPercent, model.Percent); } [Fact] public void SerializationRoundtrip_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new PercentConfig { Percent = 0 }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -8753,83 +8867,35 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new PercentConfig { Percent = 0 }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + double expectedPercent = 0; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedPercent, deserialized.Percent); } [Fact] public void Validation_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() - { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() - { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() - { - var model = new MinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() - { - var model = new MinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; + var model = new PercentConfig { Percent = 0 }; model.Validate(); } } -public class MinimumConversionRateConfigTest : TestBase +public class PercentConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + PercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -8840,7 +8906,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + PercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -8860,13 +8926,13 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + PercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8877,7 +8943,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + PercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -8892,7 +8958,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8901,17 +8967,22 @@ public void TieredSerializationRoundtripWorks() } } -public class PercentTest : TestBase +public class EventOutputTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Percent + var model = new EventOutput { - Cadence = PercentCadence.Annual, + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8944,11 +9015,16 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = PercentCadence.Annual; + ApiEnum expectedCadence = EventOutputCadence.Annual; + EventOutputConfig expectedEventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); string expectedName = "Annual fee"; - PercentConfig expectedPercentConfig = new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -8957,7 +9033,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PercentConversionRateConfig expectedConversionRateConfig = + EventOutputConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8982,10 +9058,10 @@ public void FieldRoundtrip_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedEventOutputConfig, model.EventOutputConfig); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedPercentConfig, model.PercentConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -9011,12 +9087,17 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Percent + var model = new EventOutput { - Cadence = PercentCadence.Annual, + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9050,7 +9131,10 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -9058,12 +9142,17 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Percent + var model = new EventOutput { - Cadence = PercentCadence.Annual, + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9097,17 +9186,22 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = PercentCadence.Annual; + ApiEnum expectedCadence = EventOutputCadence.Annual; + EventOutputConfig expectedEventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); string expectedName = "Annual fee"; - PercentConfig expectedPercentConfig = new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -9116,7 +9210,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PercentConversionRateConfig expectedConversionRateConfig = + EventOutputConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9141,10 +9235,10 @@ public void FieldRoundtripThroughSerialization_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedEventOutputConfig, deserialized.EventOutputConfig); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedPercentConfig, deserialized.PercentConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -9173,12 +9267,17 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Percent + var model = new EventOutput { - Cadence = PercentCadence.Annual, + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9217,12 +9316,17 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Percent + var model = new EventOutput { - Cadence = PercentCadence.Annual, + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), }; Assert.Null(model.BillableMetricID); @@ -9256,12 +9360,17 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Percent + var model = new EventOutput { - Cadence = PercentCadence.Annual, + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), }; model.Validate(); @@ -9270,12 +9379,17 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Percent + var model = new EventOutput { - Cadence = PercentCadence.Annual, + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -9323,12 +9437,17 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Percent + var model = new EventOutput { - Cadence = PercentCadence.Annual, + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -9349,26 +9468,26 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class PercentCadenceTest : TestBase +public class EventOutputCadenceTest : TestBase { [Theory] - [InlineData(PercentCadence.Annual)] - [InlineData(PercentCadence.SemiAnnual)] - [InlineData(PercentCadence.Monthly)] - [InlineData(PercentCadence.Quarterly)] - [InlineData(PercentCadence.OneTime)] - [InlineData(PercentCadence.Custom)] - public void Validation_Works(PercentCadence rawValue) + [InlineData(EventOutputCadence.Annual)] + [InlineData(EventOutputCadence.SemiAnnual)] + [InlineData(EventOutputCadence.Monthly)] + [InlineData(EventOutputCadence.Quarterly)] + [InlineData(EventOutputCadence.OneTime)] + [InlineData(EventOutputCadence.Custom)] + public void Validation_Works(EventOutputCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -9378,19 +9497,19 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(PercentCadence.Annual)] - [InlineData(PercentCadence.SemiAnnual)] - [InlineData(PercentCadence.Monthly)] - [InlineData(PercentCadence.Quarterly)] - [InlineData(PercentCadence.OneTime)] - [InlineData(PercentCadence.Custom)] - public void SerializationRoundtrip_Works(PercentCadence rawValue) + [InlineData(EventOutputCadence.Annual)] + [InlineData(EventOutputCadence.SemiAnnual)] + [InlineData(EventOutputCadence.Monthly)] + [InlineData(EventOutputCadence.Quarterly)] + [InlineData(EventOutputCadence.OneTime)] + [InlineData(EventOutputCadence.Custom)] + public void SerializationRoundtrip_Works(EventOutputCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( json, ModelBase.SerializerOptions ); @@ -9401,12 +9520,12 @@ public void SerializationRoundtrip_Works(PercentCadence rawValue) [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( json, ModelBase.SerializerOptions ); @@ -9415,25 +9534,39 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class PercentConfigTest : TestBase +public class EventOutputConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new PercentConfig { Percent = 0 }; + var model = new EventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; - double expectedPercent = 0; + string expectedUnitRatingKey = "x"; + string expectedDefaultUnitRate = "default_unit_rate"; + string expectedGroupingKey = "grouping_key"; - Assert.Equal(expectedPercent, model.Percent); + Assert.Equal(expectedUnitRatingKey, model.UnitRatingKey); + Assert.Equal(expectedDefaultUnitRate, model.DefaultUnitRate); + Assert.Equal(expectedGroupingKey, model.GroupingKey); } [Fact] public void SerializationRoundtrip_Works() { - var model = new PercentConfig { Percent = 0 }; + var model = new EventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -9444,35 +9577,99 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new PercentConfig { Percent = 0 }; + var model = new EventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - double expectedPercent = 0; + string expectedUnitRatingKey = "x"; + string expectedDefaultUnitRate = "default_unit_rate"; + string expectedGroupingKey = "grouping_key"; - Assert.Equal(expectedPercent, deserialized.Percent); + Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); + Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); } [Fact] public void Validation_Works() { - var model = new PercentConfig { Percent = 0 }; + var model = new EventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new EventOutputConfig { UnitRatingKey = "x" }; + + Assert.Null(model.DefaultUnitRate); + Assert.False(model.RawData.ContainsKey("default_unit_rate")); + Assert.Null(model.GroupingKey); + Assert.False(model.RawData.ContainsKey("grouping_key")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new EventOutputConfig { UnitRatingKey = "x" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new EventOutputConfig + { + UnitRatingKey = "x", + + DefaultUnitRate = null, + GroupingKey = null, + }; + + Assert.Null(model.DefaultUnitRate); + Assert.True(model.RawData.ContainsKey("default_unit_rate")); + Assert.Null(model.GroupingKey); + Assert.True(model.RawData.ContainsKey("grouping_key")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new EventOutputConfig + { + UnitRatingKey = "x", + + DefaultUnitRate = null, + GroupingKey = null, + }; model.Validate(); } } -public class PercentConversionRateConfigTest : TestBase +public class EventOutputConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - PercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -9483,7 +9680,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - PercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -9503,13 +9700,13 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - PercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9520,7 +9717,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - PercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -9535,7 +9732,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9544,171 +9741,27 @@ public void TieredSerializationRoundtripWorks() } } -public class EventOutputTest : TestBase +public class RemoveAdjustmentTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new EventOutput - { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; - ApiEnum expectedCadence = EventOutputCadence.Annual; - EventOutputConfig expectedEventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - EventOutputConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedEventOutputConfig, model.EventOutputConfig); - Assert.Equal(expectedItemID, model.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); - Assert.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); + string expectedAdjustmentID = "adjustment_id"; + long expectedPlanPhaseOrder = 0; - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); + Assert.Equal(expectedAdjustmentID, model.AdjustmentID); + Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); } [Fact] public void SerializationRoundtrip_Works() { - var model = new EventOutput - { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -9719,173 +9772,26 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new EventOutput - { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = EventOutputCadence.Annual; - EventOutputConfig expectedEventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - EventOutputConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedEventOutputConfig, deserialized.EventOutputConfig); - Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); + string expectedAdjustmentID = "adjustment_id"; + long expectedPlanPhaseOrder = 0; - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); } [Fact] public void Validation_Works() { - var model = new EventOutput - { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; model.Validate(); } @@ -9893,62 +9799,16 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new EventOutput - { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - }; + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id" }; - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.False(model.RawData.ContainsKey("reference_id")); + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new EventOutput - { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - }; + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id" }; model.Validate(); } @@ -9956,194 +9816,52 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new EventOutput + var model = new RemoveAdjustment { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", + AdjustmentID = "adjustment_id", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + PlanPhaseOrder = null, }; - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.True(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.True(model.RawData.ContainsKey("reference_id")); + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new EventOutput + var model = new RemoveAdjustment { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", + AdjustmentID = "adjustment_id", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + PlanPhaseOrder = null, }; model.Validate(); } } -public class EventOutputCadenceTest : TestBase -{ - [Theory] - [InlineData(EventOutputCadence.Annual)] - [InlineData(EventOutputCadence.SemiAnnual)] - [InlineData(EventOutputCadence.Monthly)] - [InlineData(EventOutputCadence.Quarterly)] - [InlineData(EventOutputCadence.OneTime)] - [InlineData(EventOutputCadence.Custom)] - public void Validation_Works(EventOutputCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(EventOutputCadence.Annual)] - [InlineData(EventOutputCadence.SemiAnnual)] - [InlineData(EventOutputCadence.Monthly)] - [InlineData(EventOutputCadence.Quarterly)] - [InlineData(EventOutputCadence.OneTime)] - [InlineData(EventOutputCadence.Custom)] - public void SerializationRoundtrip_Works(EventOutputCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - -public class EventOutputConfigTest : TestBase +public class RemovePriceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new EventOutputConfig - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; - string expectedUnitRatingKey = "x"; - string expectedDefaultUnitRate = "default_unit_rate"; - string expectedGroupingKey = "grouping_key"; + string expectedPriceID = "price_id"; + long expectedPlanPhaseOrder = 0; - Assert.Equal(expectedUnitRatingKey, model.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, model.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedPriceID, model.PriceID); + Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); } [Fact] public void SerializationRoundtrip_Works() { - var model = new EventOutputConfig - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10154,38 +9872,26 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new EventOutputConfig - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedUnitRatingKey = "x"; - string expectedDefaultUnitRate = "default_unit_rate"; - string expectedGroupingKey = "grouping_key"; + string expectedPriceID = "price_id"; + long expectedPlanPhaseOrder = 0; - Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedPriceID, deserialized.PriceID); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); } [Fact] public void Validation_Works() { - var model = new EventOutputConfig - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; model.Validate(); } @@ -10193,18 +9899,16 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new EventOutputConfig { UnitRatingKey = "x" }; + var model = new RemovePrice { PriceID = "price_id" }; - Assert.Null(model.DefaultUnitRate); - Assert.False(model.RawData.ContainsKey("default_unit_rate")); - Assert.Null(model.GroupingKey); - Assert.False(model.RawData.ContainsKey("grouping_key")); - } + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); + } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new EventOutputConfig { UnitRatingKey = "x" }; + var model = new RemovePrice { PriceID = "price_id" }; model.Validate(); } @@ -10212,133 +9916,121 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new EventOutputConfig + var model = new RemovePrice { - UnitRatingKey = "x", + PriceID = "price_id", - DefaultUnitRate = null, - GroupingKey = null, + PlanPhaseOrder = null, }; - Assert.Null(model.DefaultUnitRate); - Assert.True(model.RawData.ContainsKey("default_unit_rate")); - Assert.Null(model.GroupingKey); - Assert.True(model.RawData.ContainsKey("grouping_key")); + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new EventOutputConfig + var model = new RemovePrice { - UnitRatingKey = "x", + PriceID = "price_id", - DefaultUnitRate = null, - GroupingKey = null, + PlanPhaseOrder = null, }; model.Validate(); } } -public class EventOutputConversionRateConfigTest : TestBase +public class ReplaceAdjustmentTest : TestBase { [Fact] - public void UnitValidationWorks() - { - EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() + public void FieldRoundtrip_Works() { - EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + var model = new ReplaceAdjustment { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( + Adjustment = new Models::NewPercentageDiscount() + { + AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = [ new() { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, + Field = Models::NewPercentageDiscountFilterField.PriceID, + Operator = Models::NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], }, - ] - ), + ], + IsInvoiceLevel = true, + PriceType = Models::NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + PlanPhaseOrder = 0, }; - value.Validate(); - } - [Fact] - public void UnitSerializationRoundtripWorks() - { - EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + ReplaceAdjustmentAdjustment expectedAdjustment = new Models::NewPercentageDiscount() { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewPercentageDiscountFilterField.PriceID, + Operator = Models::NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::NewPercentageDiscountPriceType.Usage, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + string expectedReplacesAdjustmentID = "replaces_adjustment_id"; + long expectedPlanPhaseOrder = 0; - Assert.Equal(value, deserialized); + Assert.Equal(expectedAdjustment, model.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); + Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); } [Fact] - public void TieredSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + var model = new ReplaceAdjustment { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( + Adjustment = new Models::NewPercentageDiscount() + { + AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = [ new() { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, + Field = Models::NewPercentageDiscountFilterField.PriceID, + Operator = Models::NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], }, - ] - ), + ], + IsInvoiceLevel = true, + PriceType = Models::NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + PlanPhaseOrder = 0, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - -public class RemoveAdjustmentTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; - - string expectedAdjustmentID = "adjustment_id"; - long expectedPlanPhaseOrder = 0; - - Assert.Equal(expectedAdjustmentID, model.AdjustmentID); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10349,179 +10041,101 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + var model = new ReplaceAdjustment + { + Adjustment = new Models::NewPercentageDiscount() + { + AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewPercentageDiscountFilterField.PriceID, + Operator = Models::NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + PlanPhaseOrder = 0, + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedAdjustmentID = "adjustment_id"; + ReplaceAdjustmentAdjustment expectedAdjustment = new Models::NewPercentageDiscount() + { + AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewPercentageDiscountFilterField.PriceID, + Operator = Models::NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::NewPercentageDiscountPriceType.Usage, + }; + string expectedReplacesAdjustmentID = "replaces_adjustment_id"; long expectedPlanPhaseOrder = 0; - Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); + Assert.Equal(expectedAdjustment, deserialized.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); } [Fact] public void Validation_Works() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + var model = new ReplaceAdjustment + { + Adjustment = new Models::NewPercentageDiscount() + { + AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewPercentageDiscountFilterField.PriceID, + Operator = Models::NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + PlanPhaseOrder = 0, + }; model.Validate(); } [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id" }; - - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id" }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new RemoveAdjustment - { - AdjustmentID = "adjustment_id", - - PlanPhaseOrder = null, - }; - - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new RemoveAdjustment - { - AdjustmentID = "adjustment_id", - - PlanPhaseOrder = null, - }; - - model.Validate(); - } -} - -public class RemovePriceTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; - - string expectedPriceID = "price_id"; - long expectedPlanPhaseOrder = 0; - - Assert.Equal(expectedPriceID, model.PriceID); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedPriceID = "price_id"; - long expectedPlanPhaseOrder = 0; - - Assert.Equal(expectedPriceID, deserialized.PriceID); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - } - - [Fact] - public void Validation_Works() - { - var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new RemovePrice { PriceID = "price_id" }; - - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new RemovePrice { PriceID = "price_id" }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new RemovePrice - { - PriceID = "price_id", - - PlanPhaseOrder = null, - }; - - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new RemovePrice - { - PriceID = "price_id", - - PlanPhaseOrder = null, - }; - - model.Validate(); - } -} - -public class ReplaceAdjustmentTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() { var model = new ReplaceAdjustment { @@ -10546,39 +10160,14 @@ public void FieldRoundtrip_Works() PriceType = Models::NewPercentageDiscountPriceType.Usage, }, ReplacesAdjustmentID = "replaces_adjustment_id", - PlanPhaseOrder = 0, - }; - - ReplaceAdjustmentAdjustment expectedAdjustment = new Models::NewPercentageDiscount() - { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; - long expectedPlanPhaseOrder = 0; - Assert.Equal(expectedAdjustment, model.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); } [Fact] - public void SerializationRoundtrip_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { var model = new ReplaceAdjustment { @@ -10603,20 +10192,13 @@ public void SerializationRoundtrip_Works() PriceType = Models::NewPercentageDiscountPriceType.Usage, }, ReplacesAdjustmentID = "replaces_adjustment_id", - PlanPhaseOrder = 0, }; - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + model.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = new ReplaceAdjustment { @@ -10641,46 +10223,16 @@ public void FieldRoundtripThroughSerialization_Works() PriceType = Models::NewPercentageDiscountPriceType.Usage, }, ReplacesAdjustmentID = "replaces_adjustment_id", - PlanPhaseOrder = 0, - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - ReplaceAdjustmentAdjustment expectedAdjustment = new Models::NewPercentageDiscount() - { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, + PlanPhaseOrder = null, }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; - long expectedPlanPhaseOrder = 0; - Assert.Equal(expectedAdjustment, deserialized.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); } [Fact] - public void Validation_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = new ReplaceAdjustment { @@ -10705,149 +10257,20 @@ public void Validation_Works() PriceType = Models::NewPercentageDiscountPriceType.Usage, }, ReplacesAdjustmentID = "replaces_adjustment_id", - PlanPhaseOrder = 0, - }; - - model.Validate(); - } - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new ReplaceAdjustment - { - Adjustment = new Models::NewPercentageDiscount() - { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, - }, - ReplacesAdjustmentID = "replaces_adjustment_id", + PlanPhaseOrder = null, }; - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); + model.Validate(); } +} +public class ReplaceAdjustmentAdjustmentTest : TestBase +{ [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void NewPercentageDiscountValidationWorks() { - var model = new ReplaceAdjustment - { - Adjustment = new Models::NewPercentageDiscount() - { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, - }, - ReplacesAdjustmentID = "replaces_adjustment_id", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new ReplaceAdjustment - { - Adjustment = new Models::NewPercentageDiscount() - { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, - }, - ReplacesAdjustmentID = "replaces_adjustment_id", - - PlanPhaseOrder = null, - }; - - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new ReplaceAdjustment - { - Adjustment = new Models::NewPercentageDiscount() - { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, - }, - ReplacesAdjustmentID = "replaces_adjustment_id", - - PlanPhaseOrder = null, - }; - - model.Validate(); - } -} - -public class ReplaceAdjustmentAdjustmentTest : TestBase -{ - [Fact] - public void NewPercentageDiscountValidationWorks() - { - ReplaceAdjustmentAdjustment value = new Models::NewPercentageDiscount() + ReplaceAdjustmentAdjustment value = new Models::NewPercentageDiscount() { AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, PercentageDiscount = 0, @@ -13089,49 +12512,6 @@ public void CumulativeGroupedAllocationValidationWorks() value.Validate(); } - [Fact] - public void MinimumValidationWorks() - { - ReplacePricePrice value = new ReplacePricePriceMinimum() - { - Cadence = ReplacePricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - [Fact] public void NewPlanMinimumCompositeValidationWorks() { @@ -14829,1272 +14209,233 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() } [Fact] - public void CumulativeGroupedAllocationSerializationRoundtripWorks() - { - ReplacePricePrice value = new ReplacePricePriceCumulativeGroupedAllocation() - { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void MinimumSerializationRoundtripWorks() - { - ReplacePricePrice value = new ReplacePricePriceMinimum() - { - Cadence = ReplacePricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewPlanMinimumCompositeSerializationRoundtripWorks() - { - ReplacePricePrice value = new Models::NewPlanMinimumCompositePrice() - { - Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, - ItemID = "item_id", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void PercentSerializationRoundtripWorks() - { - ReplacePricePrice value = new ReplacePricePricePercent() - { - Cadence = ReplacePricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void EventOutputSerializationRoundtripWorks() - { - ReplacePricePrice value = new ReplacePricePriceEventOutput() - { - Cadence = ReplacePricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - -public class ReplacePricePriceBulkWithFiltersTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new ReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - ApiEnum expectedCadence = - ReplacePricePriceBulkWithFiltersCadence.Annual; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedBulkWithFiltersConfig, model.BulkWithFiltersConfig); - Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedItemID, model.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); - Assert.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new ReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new ReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - ApiEnum expectedCadence = - ReplacePricePriceBulkWithFiltersCadence.Annual; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedBulkWithFiltersConfig, deserialized.BulkWithFiltersConfig); - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); - } - - [Fact] - public void Validation_Works() - { - var model = new ReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new ReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - }; - - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.False(model.RawData.ContainsKey("reference_id")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new ReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new ReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; - - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.True(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.True(model.RawData.ContainsKey("reference_id")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new ReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; - - model.Validate(); - } -} - -public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - List expectedFilters = - [ - new() { PropertyKey = "x", PropertyValue = "x" }, - ]; - List expectedTiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ]; - - Assert.Equal(expectedFilters.Count, model.Filters.Count); - for (int i = 0; i < expectedFilters.Count; i++) - { - Assert.Equal(expectedFilters[i], model.Filters[i]); - } - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - List expectedFilters = - [ - new() { PropertyKey = "x", PropertyValue = "x" }, - ]; - List expectedTiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ]; - - Assert.Equal(expectedFilters.Count, deserialized.Filters.Count); - for (int i = 0; i < expectedFilters.Count; i++) - { - Assert.Equal(expectedFilters[i], deserialized.Filters[i]); - } - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); - } - } - - [Fact] - public void Validation_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - model.Validate(); - } -} - -public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - { - PropertyKey = "x", - PropertyValue = "x", - }; - - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; - - Assert.Equal(expectedPropertyKey, model.PropertyKey); - Assert.Equal(expectedPropertyValue, model.PropertyValue); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - { - PropertyKey = "x", - PropertyValue = "x", - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - { - PropertyKey = "x", - PropertyValue = "x", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; - - Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); - Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); - } - - [Fact] - public void Validation_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - { - PropertyKey = "x", - PropertyValue = "x", - }; - - model.Validate(); - } -} - -public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", - }; - - string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; - - Assert.Equal(expectedUnitAmount, model.UnitAmount); - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; - - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - } - - [Fact] - public void Validation_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - }; - - Assert.Null(model.TierLowerBound); - Assert.False(model.RawData.ContainsKey("tier_lower_bound")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - - TierLowerBound = null, - }; - - Assert.Null(model.TierLowerBound); - Assert.True(model.RawData.ContainsKey("tier_lower_bound")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - - TierLowerBound = null, - }; - - model.Validate(); - } -} - -public class ReplacePricePriceBulkWithFiltersCadenceTest : TestBase -{ - [Theory] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Annual)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.SemiAnnual)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Monthly)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Quarterly)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.OneTime)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Custom)] - public void Validation_Works(ReplacePricePriceBulkWithFiltersCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Annual)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.SemiAnnual)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Monthly)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Quarterly)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.OneTime)] - [InlineData(ReplacePricePriceBulkWithFiltersCadence.Custom)] - public void SerializationRoundtrip_Works(ReplacePricePriceBulkWithFiltersCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } -} - -public class ReplacePricePriceBulkWithFiltersConversionRateConfigTest : TestBase -{ - [Fact] - public void UnitValidationWorks() + public void CumulativeGroupedAllocationSerializationRoundtripWorks() { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = - new Models::SharedUnitConversionRateConfig() + ReplacePricePrice value = new ReplacePricePriceCumulativeGroupedAllocation() + { + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), - }; - value.Validate(); + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void TieredValidationWorks() + public void NewPlanMinimumCompositeSerializationRoundtripWorks() { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = - new Models::SharedTieredConversionRateConfig() + ReplacePricePrice value = new Models::NewPlanMinimumCompositePrice() + { + Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, + ItemID = "item_id", + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void UnitSerializationRoundtripWorks() + public void PercentSerializationRoundtripWorks() { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = - new Models::SharedUnitConversionRateConfig() + ReplacePricePrice value = new ReplacePricePricePercent() + { + Cadence = ReplacePricePricePercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), - }; + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } [Fact] - public void TieredSerializationRoundtripWorks() + public void EventOutputSerializationRoundtripWorks() { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = - new Models::SharedTieredConversionRateConfig() + ReplacePricePrice value = new ReplacePricePriceEventOutput() + { + Cadence = ReplacePricePriceEventOutputCadence.Annual, + EventOutputConfig = new() { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class ReplacePricePriceTieredWithProrationTest : TestBase +public class ReplacePricePriceBulkWithFiltersTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceBulkWithFilters { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16127,13 +14468,20 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - ReplacePricePriceTieredWithProrationCadence.Annual; + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + ApiEnum expectedCadence = + ReplacePricePriceBulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; - ReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = - new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -16142,7 +14490,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16166,11 +14514,11 @@ public void FieldRoundtrip_Works() Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; + Assert.Equal(expectedBulkWithFiltersConfig, model.BulkWithFiltersConfig); Assert.Equal(expectedCadence, model.Cadence); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -16196,14 +14544,20 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceBulkWithFilters { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16237,7 +14591,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -16248,14 +14602,20 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceBulkWithFilters { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16289,19 +14649,26 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = - ReplacePricePriceTieredWithProrationCadence.Annual; + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + ApiEnum expectedCadence = + ReplacePricePriceBulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; - ReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = - new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -16310,7 +14677,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16334,11 +14701,11 @@ public void FieldRoundtripThroughSerialization_Works() Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; + Assert.Equal(expectedBulkWithFiltersConfig, deserialized.BulkWithFiltersConfig); Assert.Equal(expectedCadence, deserialized.Cadence); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -16367,14 +14734,20 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceBulkWithFilters { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16413,14 +14786,20 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceBulkWithFilters { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; Assert.Null(model.BillableMetricID); @@ -16454,14 +14833,20 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceBulkWithFilters { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; model.Validate(); @@ -16470,14 +14855,20 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceBulkWithFilters { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -16523,131 +14914,266 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePricePriceBulkWithFilters + { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } +} + +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + List expectedFilters = + [ + new() { PropertyKey = "x", PropertyValue = "x" }, + ]; + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedFilters.Count, model.Filters.Count); + for (int i = 0; i < expectedFilters.Count; i++) + { + Assert.Equal(expectedFilters[i], model.Filters[i]); + } + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedFilters = + [ + new() { PropertyKey = "x", PropertyValue = "x" }, + ]; + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedFilters.Count, deserialized.Filters.Count); + for (int i = 0; i < expectedFilters.Count; i++) + { + Assert.Equal(expectedFilters[i], deserialized.Filters[i]); + } + Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + } + } + + [Fact] + public void Validation_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }; model.Validate(); } } -public class ReplacePricePriceTieredWithProrationCadenceTest : TestBase +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase { - [Theory] - [InlineData(ReplacePricePriceTieredWithProrationCadence.Annual)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.SemiAnnual)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.Monthly)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.Quarterly)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.OneTime)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.Custom)] - public void Validation_Works(ReplacePricePriceTieredWithProrationCadence rawValue) + [Fact] + public void FieldRoundtrip_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + string expectedPropertyKey = "x"; + string expectedPropertyValue = "x"; + + Assert.Equal(expectedPropertyKey, model.PropertyKey); + Assert.Equal(expectedPropertyValue, model.PropertyValue); } [Fact] - public void InvalidEnumValidationThrows_Works() + public void SerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } - [Theory] - [InlineData(ReplacePricePriceTieredWithProrationCadence.Annual)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.SemiAnnual)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.Monthly)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.Quarterly)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.OneTime)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.Custom)] - public void SerializationRoundtrip_Works(ReplacePricePriceTieredWithProrationCadence rawValue) + [Fact] + public void FieldRoundtripThroughSerialization_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); - Assert.Equal(value, deserialized); + string expectedPropertyKey = "x"; + string expectedPropertyValue = "x"; + + Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); + Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void Validation_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; - Assert.Equal(value, deserialized); + model.Validate(); } } -public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTest : TestBase +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; + string expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); } [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -16658,123 +15184,158 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; + string expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); - } + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); } [Fact] public void Validation_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; model.Validate(); } -} -public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", }; - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + } - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, + }; + + Assert.Null(model.TierLowerBound); + Assert.True(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, + }; + + model.Validate(); + } +} + +public class ReplacePricePriceBulkWithFiltersCadenceTest : TestBase +{ + [Theory] + [InlineData(ReplacePricePriceBulkWithFiltersCadence.Annual)] + [InlineData(ReplacePricePriceBulkWithFiltersCadence.SemiAnnual)] + [InlineData(ReplacePricePriceBulkWithFiltersCadence.Monthly)] + [InlineData(ReplacePricePriceBulkWithFiltersCadence.Quarterly)] + [InlineData(ReplacePricePriceBulkWithFiltersCadence.OneTime)] + [InlineData(ReplacePricePriceBulkWithFiltersCadence.Custom)] + public void Validation_Works(ReplacePricePriceBulkWithFiltersCadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void InvalidEnumValidationThrows_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - Assert.Equal(model, deserialized); + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); } - [Fact] - public void FieldRoundtripThroughSerialization_Works() + [Theory] + [InlineData(ReplacePricePriceBulkWithFiltersCadence.Annual)] + [InlineData(ReplacePricePriceBulkWithFiltersCadence.SemiAnnual)] + [InlineData(ReplacePricePriceBulkWithFiltersCadence.Monthly)] + [InlineData(ReplacePricePriceBulkWithFiltersCadence.Quarterly)] + [InlineData(ReplacePricePriceBulkWithFiltersCadence.OneTime)] + [InlineData(ReplacePricePriceBulkWithFiltersCadence.Custom)] + public void SerializationRoundtrip_Works(ReplacePricePriceBulkWithFiltersCadence rawValue) { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void InvalidEnumSerializationRoundtrip_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); - model.Validate(); + Assert.Equal(value, deserialized); } } -public class ReplacePricePriceTieredWithProrationConversionRateConfigTest : TestBase +public class ReplacePricePriceBulkWithFiltersConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceBulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16786,7 +15347,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceBulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -16807,7 +15368,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceBulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16815,7 +15376,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16826,7 +15387,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceBulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -16843,7 +15404,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16852,23 +15413,19 @@ public void TieredSerializationRoundtripWorks() } } -public class ReplacePricePriceGroupedWithMinMaxThresholdsTest : TestBase +public class ReplacePricePriceTieredWithProrationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceTieredWithProration { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16901,21 +15458,13 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = - new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + ApiEnum expectedCadence = + ReplacePricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; + ReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -16924,7 +15473,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16949,13 +15498,10 @@ public void FieldRoundtrip_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal( - expectedGroupedWithMinMaxThresholdsConfig, - model.GroupedWithMinMaxThresholdsConfig - ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -16981,18 +15527,14 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceTieredWithProration { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -17026,7 +15568,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -17037,18 +15579,14 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceTieredWithProration { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -17082,27 +15620,19 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = - new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + ApiEnum expectedCadence = + ReplacePricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; + ReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -17111,7 +15641,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17136,13 +15666,10 @@ public void FieldRoundtripThroughSerialization_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal( - expectedGroupedWithMinMaxThresholdsConfig, - deserialized.GroupedWithMinMaxThresholdsConfig - ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -17171,18 +15698,14 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceTieredWithProration { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -17221,18 +15744,14 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceTieredWithProration { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; Assert.Null(model.BillableMetricID); @@ -17266,18 +15785,14 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceTieredWithProration { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; model.Validate(); @@ -17286,18 +15801,14 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceTieredWithProration { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -17343,20 +15854,16 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds - { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new ReplacePricePriceTieredWithProration + { + Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -17377,19 +15884,19 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest : TestBase +public class ReplacePricePriceTieredWithProrationCadenceTest : TestBase { [Theory] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] - public void Validation_Works(ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue) + [InlineData(ReplacePricePriceTieredWithProrationCadence.Annual)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.SemiAnnual)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.Monthly)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.Quarterly)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.OneTime)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.Custom)] + public void Validation_Works(ReplacePricePriceTieredWithProrationCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -17397,7 +15904,7 @@ public void Validation_Works(ReplacePricePriceGroupedWithMinMaxThresholdsCadence public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -17405,22 +15912,20 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] - public void SerializationRoundtrip_Works( - ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue - ) + [InlineData(ReplacePricePriceTieredWithProrationCadence.Annual)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.SemiAnnual)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.Monthly)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.Quarterly)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.OneTime)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works(ReplacePricePriceTieredWithProrationCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -17430,58 +15935,50 @@ ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest - : TestBase +public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = - new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } } [Fact] public void SerializationRoundtrip_Works() { - var model = - new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -17492,56 +15989,123 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = - new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); - Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); - Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); + Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + } } [Fact] public void Validation_Works() { - var model = - new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; model.Validate(); } } -public class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } +} + +public class ReplacePricePriceTieredWithProrationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17553,7 +16117,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -17574,7 +16138,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17582,7 +16146,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17593,7 +16157,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -17610,7 +16174,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17619,20 +16183,20 @@ public void TieredSerializationRoundtripWorks() } } -public class ReplacePricePriceCumulativeGroupedAllocationTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -17668,19 +16232,19 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + ApiEnum expectedCadence = + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" + "grouped_with_min_max_thresholds" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -17691,7 +16255,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17717,8 +16281,8 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedCadence, model.Cadence); Assert.Equal( - expectedCumulativeGroupedAllocationConfig, - model.CumulativeGroupedAllocationConfig + expectedGroupedWithMinMaxThresholdsConfig, + model.GroupedWithMinMaxThresholdsConfig ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); @@ -17748,15 +16312,15 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -17793,7 +16357,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -17804,15 +16368,15 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -17849,25 +16413,25 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = - ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + ApiEnum expectedCadence = + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" + "grouped_with_min_max_thresholds" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -17878,7 +16442,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17904,8 +16468,8 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedCadence, deserialized.Cadence); Assert.Equal( - expectedCumulativeGroupedAllocationConfig, - deserialized.CumulativeGroupedAllocationConfig + expectedGroupedWithMinMaxThresholdsConfig, + deserialized.GroupedWithMinMaxThresholdsConfig ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); @@ -17938,15 +16502,15 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -17988,15 +16552,15 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -18033,15 +16597,15 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -18053,15 +16617,15 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -18112,15 +16676,15 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -18144,19 +16708,19 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class ReplacePricePriceCumulativeGroupedAllocationCadenceTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest : TestBase { [Theory] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] - public void Validation_Works(ReplacePricePriceCumulativeGroupedAllocationCadence rawValue) + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] + public void Validation_Works(ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -18164,7 +16728,7 @@ public void Validation_Works(ReplacePricePriceCumulativeGroupedAllocationCadence public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -18172,22 +16736,22 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] public void SerializationRoundtrip_Works( - ReplacePricePriceCumulativeGroupedAllocationCadence rawValue + ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -18197,58 +16761,58 @@ ReplacePricePriceCumulativeGroupedAllocationCadence rawValue public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest +public class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedMaximumCharge, model.MaximumCharge); + Assert.Equal(expectedMinimumCharge, model.MinimumCharge); + Assert.Equal(expectedPerUnitRate, model.PerUnitRate); } [Fact] public void SerializationRoundtrip_Works() { var model = - new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18260,55 +16824,55 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); + Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); + Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); } [Fact] public void Validation_Works() { var model = - new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; model.Validate(); } } -public class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18320,7 +16884,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -18341,7 +16905,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18349,7 +16913,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18360,7 +16924,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -18377,7 +16941,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18386,16 +16950,22 @@ public void TieredSerializationRoundtripWorks() } } -public class ReplacePricePriceMinimumTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -18429,15 +16999,20 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - ReplacePricePriceMinimumCadence.Annual; + ApiEnum expectedCadence = + ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - ReplacePricePriceMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -18447,7 +17022,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18472,8 +17047,11 @@ public void FieldRoundtrip_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + model.CumulativeGroupedAllocationConfig + ); Assert.Equal(expectedItemID, model.ItemID); - Assert.Equal(expectedMinimumConfig, model.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -18501,11 +17079,17 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -18540,7 +17124,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18551,11 +17135,17 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -18590,21 +17180,26 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = - ReplacePricePriceMinimumCadence.Annual; + ApiEnum expectedCadence = + ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - ReplacePricePriceMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -18614,7 +17209,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18639,8 +17234,11 @@ public void FieldRoundtripThroughSerialization_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + deserialized.CumulativeGroupedAllocationConfig + ); Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.Equal(expectedMinimumConfig, deserialized.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -18671,11 +17269,17 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -18715,11 +17319,17 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", }; @@ -18754,11 +17364,17 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", }; @@ -18768,11 +17384,17 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = null, @@ -18821,11 +17443,17 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = null, @@ -18847,49 +17475,50 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class ReplacePricePriceMinimumCadenceTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationCadenceTest : TestBase { [Theory] - [InlineData(ReplacePricePriceMinimumCadence.Annual)] - [InlineData(ReplacePricePriceMinimumCadence.SemiAnnual)] - [InlineData(ReplacePricePriceMinimumCadence.Monthly)] - [InlineData(ReplacePricePriceMinimumCadence.Quarterly)] - [InlineData(ReplacePricePriceMinimumCadence.OneTime)] - [InlineData(ReplacePricePriceMinimumCadence.Custom)] - public void Validation_Works(ReplacePricePriceMinimumCadence rawValue) + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] + public void Validation_Works(ReplacePricePriceCumulativeGroupedAllocationCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); Assert.Throws(() => value.Validate()); } [Theory] - [InlineData(ReplacePricePriceMinimumCadence.Annual)] - [InlineData(ReplacePricePriceMinimumCadence.SemiAnnual)] - [InlineData(ReplacePricePriceMinimumCadence.Monthly)] - [InlineData(ReplacePricePriceMinimumCadence.Quarterly)] - [InlineData(ReplacePricePriceMinimumCadence.OneTime)] - [InlineData(ReplacePricePriceMinimumCadence.Custom)] - public void SerializationRoundtrip_Works(ReplacePricePriceMinimumCadence rawValue) + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePricePriceCumulativeGroupedAllocationCadence rawValue + ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -18898,51 +17527,62 @@ public void SerializationRoundtrip_Works(ReplacePricePriceMinimumCadence rawValu [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class ReplacePricePriceMinimumMinimumConfigTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, model.GroupAllocation); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -18950,91 +17590,56 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() - { - var model = new ReplacePricePriceMinimumMinimumConfig { MinimumAmount = "minimum_amount" }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() - { - var model = new ReplacePricePriceMinimumMinimumConfig { MinimumAmount = "minimum_amount" }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() - { - var model = new ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() - { - var model = new ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; + var model = + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; model.Validate(); } } -public class ReplacePricePriceMinimumConversionRateConfigTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19046,7 +17651,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -19067,17 +17672,18 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -19085,7 +17691,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -19101,10 +17707,11 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } diff --git a/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDFetchPlanVersionParamsTest.cs b/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDFetchPlanVersionParamsTest.cs index 7663b346..5d64d6d4 100644 --- a/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDFetchPlanVersionParamsTest.cs +++ b/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDFetchPlanVersionParamsTest.cs @@ -39,4 +39,18 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ExternalPlanIDFetchPlanVersionParams + { + ExternalPlanID = "external_plan_id", + Version = "version", + }; + + ExternalPlanIDFetchPlanVersionParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDSetDefaultPlanVersionParamsTest.cs b/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDSetDefaultPlanVersionParamsTest.cs index a8067fbc..68dbc82d 100644 --- a/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDSetDefaultPlanVersionParamsTest.cs +++ b/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDSetDefaultPlanVersionParamsTest.cs @@ -39,4 +39,18 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ExternalPlanIDSetDefaultPlanVersionParams + { + ExternalPlanID = "external_plan_id", + Version = 0, + }; + + ExternalPlanIDSetDefaultPlanVersionParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Coupons/CouponArchiveParamsTest.cs b/src/Orb.Tests/Models/Coupons/CouponArchiveParamsTest.cs index cbc8c846..5ad2b2d7 100644 --- a/src/Orb.Tests/Models/Coupons/CouponArchiveParamsTest.cs +++ b/src/Orb.Tests/Models/Coupons/CouponArchiveParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/coupons/coupon_id/archive"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CouponArchiveParams { CouponID = "coupon_id" }; + + CouponArchiveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Coupons/CouponCreateParamsTest.cs b/src/Orb.Tests/Models/Coupons/CouponCreateParamsTest.cs index ce6219e7..8a98bf6f 100644 --- a/src/Orb.Tests/Models/Coupons/CouponCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Coupons/CouponCreateParamsTest.cs @@ -75,6 +75,22 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/coupons"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CouponCreateParams + { + Discount = new Percentage(0), + RedemptionCode = "HALFOFF", + DurationInMonths = 12, + MaxRedemptions = 1, + }; + + CouponCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class DiscountTest : TestBase diff --git a/src/Orb.Tests/Models/Coupons/CouponFetchParamsTest.cs b/src/Orb.Tests/Models/Coupons/CouponFetchParamsTest.cs index a5bf9eb4..b0a9fb78 100644 --- a/src/Orb.Tests/Models/Coupons/CouponFetchParamsTest.cs +++ b/src/Orb.Tests/Models/Coupons/CouponFetchParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/coupons/coupon_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CouponFetchParams { CouponID = "coupon_id" }; + + CouponFetchParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Coupons/CouponListParamsTest.cs b/src/Orb.Tests/Models/Coupons/CouponListParamsTest.cs index 48ae0f55..5345b145 100644 --- a/src/Orb.Tests/Models/Coupons/CouponListParamsTest.cs +++ b/src/Orb.Tests/Models/Coupons/CouponListParamsTest.cs @@ -111,4 +111,20 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CouponListParams + { + Cursor = "cursor", + Limit = 1, + RedemptionCode = "redemption_code", + ShowArchived = true, + }; + + CouponListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Coupons/Subscriptions/SubscriptionListParamsTest.cs b/src/Orb.Tests/Models/Coupons/Subscriptions/SubscriptionListParamsTest.cs index a327c660..e823286e 100644 --- a/src/Orb.Tests/Models/Coupons/Subscriptions/SubscriptionListParamsTest.cs +++ b/src/Orb.Tests/Models/Coupons/Subscriptions/SubscriptionListParamsTest.cs @@ -92,4 +92,19 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionListParams + { + CouponID = "coupon_id", + Cursor = "cursor", + Limit = 1, + }; + + SubscriptionListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/CreditBlocks/CreditBlockDeleteParamsTest.cs b/src/Orb.Tests/Models/CreditBlocks/CreditBlockDeleteParamsTest.cs index e601cd0f..7561c55e 100644 --- a/src/Orb.Tests/Models/CreditBlocks/CreditBlockDeleteParamsTest.cs +++ b/src/Orb.Tests/Models/CreditBlocks/CreditBlockDeleteParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/credit_blocks/block_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CreditBlockDeleteParams { BlockID = "block_id" }; + + CreditBlockDeleteParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/CreditBlocks/CreditBlockRetrieveParamsTest.cs b/src/Orb.Tests/Models/CreditBlocks/CreditBlockRetrieveParamsTest.cs index 4ac40507..a9b6654f 100644 --- a/src/Orb.Tests/Models/CreditBlocks/CreditBlockRetrieveParamsTest.cs +++ b/src/Orb.Tests/Models/CreditBlocks/CreditBlockRetrieveParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/credit_blocks/block_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CreditBlockRetrieveParams { BlockID = "block_id" }; + + CreditBlockRetrieveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/CreditNotes/CreditNoteCreateParamsTest.cs b/src/Orb.Tests/Models/CreditNotes/CreditNoteCreateParamsTest.cs index b4d7d46a..052af5b3 100644 --- a/src/Orb.Tests/Models/CreditNotes/CreditNoteCreateParamsTest.cs +++ b/src/Orb.Tests/Models/CreditNotes/CreditNoteCreateParamsTest.cs @@ -134,6 +134,32 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/credit_notes"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CreditNoteCreateParams + { + LineItems = + [ + new() + { + Amount = "amount", + InvoiceLineItemID = "4khy3nwzktxv7", + EndDate = "2023-09-22", + StartDate = "2023-09-22", + }, + ], + Reason = Reason.Duplicate, + EndDate = "2023-09-22", + Memo = "An optional memo for my credit note.", + StartDate = "2023-09-22", + }; + + CreditNoteCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class LineItemTest : TestBase diff --git a/src/Orb.Tests/Models/CreditNotes/CreditNoteFetchParamsTest.cs b/src/Orb.Tests/Models/CreditNotes/CreditNoteFetchParamsTest.cs index db988248..3870fde6 100644 --- a/src/Orb.Tests/Models/CreditNotes/CreditNoteFetchParamsTest.cs +++ b/src/Orb.Tests/Models/CreditNotes/CreditNoteFetchParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/credit_notes/credit_note_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CreditNoteFetchParams { CreditNoteID = "credit_note_id" }; + + CreditNoteFetchParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/CreditNotes/CreditNoteListParamsTest.cs b/src/Orb.Tests/Models/CreditNotes/CreditNoteListParamsTest.cs index 2ada0751..048ded86 100644 --- a/src/Orb.Tests/Models/CreditNotes/CreditNoteListParamsTest.cs +++ b/src/Orb.Tests/Models/CreditNotes/CreditNoteListParamsTest.cs @@ -133,4 +133,22 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CreditNoteListParams + { + CreatedAtGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAtGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAtLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAtLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Cursor = "cursor", + Limit = 1, + }; + + CreditNoteListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionCreateParamsTest.cs b/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionCreateParamsTest.cs index b469a1d4..3ed4af60 100644 --- a/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionCreateParamsTest.cs @@ -78,6 +78,22 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BalanceTransactions::BalanceTransactionCreateParams + { + CustomerID = "customer_id", + Amount = "amount", + Type = BalanceTransactions::Type.Increment, + Description = "description", + }; + + BalanceTransactions::BalanceTransactionCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class TypeTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionListParamsTest.cs b/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionListParamsTest.cs index a008e606..29d3c4dd 100644 --- a/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionListParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionListParamsTest.cs @@ -140,4 +140,23 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BalanceTransactionListParams + { + CustomerID = "customer_id", + Cursor = "cursor", + Limit = 1, + OperationTimeGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + OperationTimeGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + OperationTimeLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + OperationTimeLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + BalanceTransactionListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/Costs/CostListByExternalIDParamsTest.cs b/src/Orb.Tests/Models/Customers/Costs/CostListByExternalIDParamsTest.cs index 740995ac..4bf55259 100644 --- a/src/Orb.Tests/Models/Customers/Costs/CostListByExternalIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Costs/CostListByExternalIDParamsTest.cs @@ -96,6 +96,23 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CostListByExternalIDParams + { + ExternalCustomerID = "external_customer_id", + Currency = "currency", + TimeframeEnd = DateTimeOffset.Parse("2022-03-01T05:00:00Z"), + TimeframeStart = DateTimeOffset.Parse("2022-02-01T05:00:00Z"), + ViewMode = CostListByExternalIDParamsViewMode.Periodic, + }; + + CostListByExternalIDParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class CostListByExternalIDParamsViewModeTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/Costs/CostListParamsTest.cs b/src/Orb.Tests/Models/Customers/Costs/CostListParamsTest.cs index f828062a..8d6bcb18 100644 --- a/src/Orb.Tests/Models/Customers/Costs/CostListParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Costs/CostListParamsTest.cs @@ -92,6 +92,23 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CostListParams + { + CustomerID = "customer_id", + Currency = "currency", + TimeframeEnd = DateTimeOffset.Parse("2022-03-01T05:00:00Z"), + TimeframeStart = DateTimeOffset.Parse("2022-02-01T05:00:00Z"), + ViewMode = ViewMode.Periodic, + }; + + CostListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class ViewModeTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDParamsTest.cs b/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDParamsTest.cs index 5f8fe537..7d512862 100644 --- a/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDParamsTest.cs @@ -122,4 +122,21 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CreditListByExternalIDParams + { + ExternalCustomerID = "external_customer_id", + Currency = "currency", + Cursor = "cursor", + IncludeAllBlocks = true, + Limit = 1, + }; + + CreditListByExternalIDParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/Credits/CreditListParamsTest.cs b/src/Orb.Tests/Models/Customers/Credits/CreditListParamsTest.cs index b00d7ced..422638a8 100644 --- a/src/Orb.Tests/Models/Customers/Credits/CreditListParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/CreditListParamsTest.cs @@ -122,4 +122,21 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CreditListParams + { + CustomerID = "customer_id", + Currency = "currency", + Cursor = "cursor", + IncludeAllBlocks = true, + Limit = 1, + }; + + CreditListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParamsTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParamsTest.cs index 52d83f73..03ea7b75 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParamsTest.cs @@ -131,6 +131,49 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new LedgerCreateEntryByExternalIDParams + { + ExternalCustomerID = "external_customer_id", + Body = new LedgerCreateEntryByExternalIDParamsBodyIncrement() + { + Amount = 0, + Currency = "currency", + Description = "description", + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = LedgerCreateEntryByExternalIDParamsBodyIncrementFilterField.ItemID, + Operator = + LedgerCreateEntryByExternalIDParamsBodyIncrementFilterOperator.Includes, + Values = ["string"], + }, + ], + InvoiceSettings = new() + { + AutoCollection = true, + CustomDueDate = "2019-12-27", + InvoiceDate = "2019-12-27", + ItemID = "item_id", + Memo = "memo", + NetTerms = 0, + RequireSuccessfulPayment = true, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }, + }; + + LedgerCreateEntryByExternalIDParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class LedgerCreateEntryByExternalIDParamsBodyTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryParamsTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryParamsTest.cs index a21e4975..0128774f 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryParamsTest.cs @@ -125,6 +125,48 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new Ledger::LedgerCreateEntryParams + { + CustomerID = "customer_id", + Body = new Ledger::Increment() + { + Amount = 0, + Currency = "currency", + Description = "description", + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExpiryDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filters = + [ + new() + { + Field = Ledger::Field.ItemID, + Operator = Ledger::Operator.Includes, + Values = ["string"], + }, + ], + InvoiceSettings = new() + { + AutoCollection = true, + CustomDueDate = "2019-12-27", + InvoiceDate = "2019-12-27", + ItemID = "item_id", + Memo = "memo", + NetTerms = 0, + RequireSuccessfulPayment = true, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + }, + }; + + Ledger::LedgerCreateEntryParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class BodyTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListByExternalIDParamsTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListByExternalIDParamsTest.cs index 401a7224..2c69e131 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListByExternalIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListByExternalIDParamsTest.cs @@ -193,6 +193,29 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new LedgerListByExternalIDParams + { + ExternalCustomerID = "external_customer_id", + CreatedAtGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAtGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAtLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAtLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Currency = "currency", + Cursor = "cursor", + EntryStatus = LedgerListByExternalIDParamsEntryStatus.Committed, + EntryType = LedgerListByExternalIDParamsEntryType.Increment, + Limit = 1, + MinimumAmount = "minimum_amount", + }; + + LedgerListByExternalIDParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class LedgerListByExternalIDParamsEntryStatusTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListParamsTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListParamsTest.cs index b46b360a..86869db4 100644 --- a/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerListParamsTest.cs @@ -187,6 +187,29 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new LedgerListParams + { + CustomerID = "customer_id", + CreatedAtGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAtGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAtLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAtLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Currency = "currency", + Cursor = "cursor", + EntryStatus = EntryStatus.Committed, + EntryType = EntryType.Increment, + Limit = 1, + MinimumAmount = "minimum_amount", + }; + + LedgerListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class EntryStatusTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParamsTest.cs b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParamsTest.cs index dbd7568a..14bad122 100644 --- a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParamsTest.cs @@ -144,6 +144,33 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TopUpCreateByExternalIDParams + { + ExternalCustomerID = "external_customer_id", + Amount = "amount", + Currency = "currency", + InvoiceSettings = new() + { + AutoCollection = true, + NetTerms = 0, + Memo = "memo", + RequireSuccessfulPayment = true, + }, + PerUnitCostBasis = "per_unit_cost_basis", + Threshold = "threshold", + ActiveFrom = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExpiresAfter = 0, + ExpiresAfterUnit = TopUpCreateByExternalIDParamsExpiresAfterUnit.Day, + }; + + TopUpCreateByExternalIDParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class TopUpCreateByExternalIDParamsInvoiceSettingsTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateParamsTest.cs b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateParamsTest.cs index 9fa88d82..3d36144c 100644 --- a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpCreateParamsTest.cs @@ -141,6 +141,33 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TopUpCreateParams + { + CustomerID = "customer_id", + Amount = "amount", + Currency = "currency", + InvoiceSettings = new() + { + AutoCollection = true, + NetTerms = 0, + Memo = "memo", + RequireSuccessfulPayment = true, + }, + PerUnitCostBasis = "per_unit_cost_basis", + Threshold = "threshold", + ActiveFrom = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExpiresAfter = 0, + ExpiresAfterUnit = ExpiresAfterUnit.Day, + }; + + TopUpCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class InvoiceSettingsTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpDeleteByExternalIDParamsTest.cs b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpDeleteByExternalIDParamsTest.cs index 825b4785..f9418b5e 100644 --- a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpDeleteByExternalIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpDeleteByExternalIDParamsTest.cs @@ -39,4 +39,18 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TopUpDeleteByExternalIDParams + { + ExternalCustomerID = "external_customer_id", + TopUpID = "top_up_id", + }; + + TopUpDeleteByExternalIDParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpDeleteParamsTest.cs b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpDeleteParamsTest.cs index 28d6de9e..a404aa14 100644 --- a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpDeleteParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpDeleteParamsTest.cs @@ -33,4 +33,18 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TopUpDeleteParams + { + CustomerID = "customer_id", + TopUpID = "top_up_id", + }; + + TopUpDeleteParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListByExternalIDParamsTest.cs b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListByExternalIDParamsTest.cs index 9e1131b1..515bacfe 100644 --- a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListByExternalIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListByExternalIDParamsTest.cs @@ -100,4 +100,19 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TopUpListByExternalIDParams + { + ExternalCustomerID = "external_customer_id", + Cursor = "cursor", + Limit = 1, + }; + + TopUpListByExternalIDParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListParamsTest.cs b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListParamsTest.cs index 5ba2f6b9..90e31cc5 100644 --- a/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/Credits/TopUps/TopUpListParamsTest.cs @@ -92,4 +92,19 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TopUpListParams + { + CustomerID = "customer_id", + Cursor = "cursor", + Limit = 1, + }; + + TopUpListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/CustomerCreateParamsTest.cs b/src/Orb.Tests/Models/Customers/CustomerCreateParamsTest.cs index 578e3638..18e20a11 100644 --- a/src/Orb.Tests/Models/Customers/CustomerCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerCreateParamsTest.cs @@ -315,6 +315,90 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/customers"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CustomerCreateParams + { + Email = "dev@stainless.com", + Name = "x", + AccountingSyncConfiguration = new() + { + AccountingProviders = + [ + new() + { + ExternalProviderID = "external_provider_id", + ProviderType = "provider_type", + }, + ], + Excluded = true, + }, + AdditionalEmails = ["dev@stainless.com"], + AutoCollection = true, + AutoIssuance = true, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Currency = "currency", + EmailDelivery = true, + ExternalCustomerID = "external_customer_id", + Hierarchy = new() + { + ChildCustomerIds = ["string"], + ParentCustomerID = "parent_customer_id", + }, + Metadata = new Dictionary() { { "foo", "string" } }, + PaymentConfiguration = new() + { + PaymentProviders = + [ + new() + { + ProviderType = ProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }, + PaymentProvider = CustomerCreateParamsPaymentProvider.Quickbooks, + PaymentProviderID = "payment_provider_id", + ReportingConfiguration = new(true), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + TaxConfiguration = new NewAvalaraTaxConfiguration() + { + TaxExempt = true, + TaxProvider = TaxProvider.Avalara, + AutomaticTaxEnabled = true, + TaxExemptionCode = "tax_exemption_code", + }, + TaxID = new() + { + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }, + Timezone = "timezone", + }; + + CustomerCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class PaymentConfigurationTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/CustomerDeleteParamsTest.cs b/src/Orb.Tests/Models/Customers/CustomerDeleteParamsTest.cs index 5c2adf1c..c4909f1d 100644 --- a/src/Orb.Tests/Models/Customers/CustomerDeleteParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerDeleteParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/customers/customer_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CustomerDeleteParams { CustomerID = "customer_id" }; + + CustomerDeleteParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/CustomerFetchByExternalIDParamsTest.cs b/src/Orb.Tests/Models/Customers/CustomerFetchByExternalIDParamsTest.cs index efdeec11..e35194d3 100644 --- a/src/Orb.Tests/Models/Customers/CustomerFetchByExternalIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerFetchByExternalIDParamsTest.cs @@ -35,4 +35,17 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CustomerFetchByExternalIDParams + { + ExternalCustomerID = "external_customer_id", + }; + + CustomerFetchByExternalIDParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/CustomerFetchParamsTest.cs b/src/Orb.Tests/Models/Customers/CustomerFetchParamsTest.cs index 7cd3f398..13c6b35e 100644 --- a/src/Orb.Tests/Models/Customers/CustomerFetchParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerFetchParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/customers/customer_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CustomerFetchParams { CustomerID = "customer_id" }; + + CustomerFetchParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/CustomerListParamsTest.cs b/src/Orb.Tests/Models/Customers/CustomerListParamsTest.cs index c88cd0d4..718f1fff 100644 --- a/src/Orb.Tests/Models/Customers/CustomerListParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerListParamsTest.cs @@ -133,4 +133,22 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CustomerListParams + { + CreatedAtGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAtGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAtLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAtLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Cursor = "cursor", + Limit = 1, + }; + + CustomerListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParamsTest.cs b/src/Orb.Tests/Models/Customers/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParamsTest.cs index 84558ee8..4eff7bae 100644 --- a/src/Orb.Tests/Models/Customers/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParamsTest.cs @@ -35,4 +35,17 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams + { + ExternalCustomerID = "external_customer_id", + }; + + CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/CustomerSyncPaymentMethodsFromGatewayParamsTest.cs b/src/Orb.Tests/Models/Customers/CustomerSyncPaymentMethodsFromGatewayParamsTest.cs index 25cf5123..fe9b6b4b 100644 --- a/src/Orb.Tests/Models/Customers/CustomerSyncPaymentMethodsFromGatewayParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerSyncPaymentMethodsFromGatewayParamsTest.cs @@ -35,4 +35,17 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CustomerSyncPaymentMethodsFromGatewayParams + { + CustomerID = "customer_id", + }; + + CustomerSyncPaymentMethodsFromGatewayParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/CustomerUpdateByExternalIDParamsTest.cs b/src/Orb.Tests/Models/Customers/CustomerUpdateByExternalIDParamsTest.cs index f30346ca..fac4b661 100644 --- a/src/Orb.Tests/Models/Customers/CustomerUpdateByExternalIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerUpdateByExternalIDParamsTest.cs @@ -327,6 +327,91 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CustomerUpdateByExternalIDParams + { + ID = "external_customer_id", + AccountingSyncConfiguration = new() + { + AccountingProviders = + [ + new() + { + ExternalProviderID = "external_provider_id", + ProviderType = "provider_type", + }, + ], + Excluded = true, + }, + AdditionalEmails = ["string"], + AutoCollection = true, + AutoIssuance = true, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Currency = "currency", + Email = "dev@stainless.com", + EmailDelivery = true, + ExternalCustomerID = "external_customer_id", + Hierarchy = new() + { + ChildCustomerIds = ["string"], + ParentCustomerID = "parent_customer_id", + }, + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + PaymentConfiguration = new() + { + PaymentProviders = + [ + new() + { + ProviderType = + CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }, + PaymentProvider = CustomerUpdateByExternalIDParamsPaymentProvider.Quickbooks, + PaymentProviderID = "payment_provider_id", + ReportingConfiguration = new(true), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + TaxConfiguration = new NewAvalaraTaxConfiguration() + { + TaxExempt = true, + TaxProvider = TaxProvider.Avalara, + AutomaticTaxEnabled = true, + TaxExemptionCode = "tax_exemption_code", + }, + TaxID = new() + { + Country = Country.Ad, + Type = CustomerTaxIDType.AdNrt, + Value = "value", + }, + }; + + CustomerUpdateByExternalIDParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class CustomerUpdateByExternalIDParamsPaymentConfigurationTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/CustomerUpdateParamsTest.cs b/src/Orb.Tests/Models/Customers/CustomerUpdateParamsTest.cs index 7df9fd35..42a77ed1 100644 --- a/src/Orb.Tests/Models/Customers/CustomerUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerUpdateParamsTest.cs @@ -322,6 +322,91 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/customers/customer_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CustomerUpdateParams + { + CustomerID = "customer_id", + AccountingSyncConfiguration = new() + { + AccountingProviders = + [ + new() + { + ExternalProviderID = "external_provider_id", + ProviderType = "provider_type", + }, + ], + Excluded = true, + }, + AdditionalEmails = ["string"], + AutoCollection = true, + AutoIssuance = true, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Currency = "currency", + Email = "dev@stainless.com", + EmailDelivery = true, + ExternalCustomerID = "external_customer_id", + Hierarchy = new() + { + ChildCustomerIds = ["string"], + ParentCustomerID = "parent_customer_id", + }, + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + PaymentConfiguration = new() + { + PaymentProviders = + [ + new() + { + ProviderType = + CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }, + PaymentProvider = CustomerUpdateParamsPaymentProvider.Quickbooks, + PaymentProviderID = "payment_provider_id", + ReportingConfiguration = new(true), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + TaxConfiguration = new NewAvalaraTaxConfiguration() + { + TaxExempt = true, + TaxProvider = TaxProvider.Avalara, + AutomaticTaxEnabled = true, + TaxExemptionCode = "tax_exemption_code", + }, + TaxID = new() + { + Country = Country.Ad, + Type = CustomerTaxIDType.AdNrt, + Value = "value", + }, + }; + + CustomerUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class CustomerUpdateParamsPaymentConfigurationTest : TestBase diff --git a/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupCreateParamsTest.cs b/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupCreateParamsTest.cs index 32314559..9ba874e3 100644 --- a/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupCreateParamsTest.cs +++ b/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupCreateParamsTest.cs @@ -94,4 +94,21 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/dimensional_price_groups"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new DimensionalPriceGroupCreateParams + { + BillableMetricID = "billable_metric_id", + Dimensions = ["region", "instance_type"], + Name = "name", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + DimensionalPriceGroupCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupListParamsTest.cs b/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupListParamsTest.cs index 318e099c..821f87ff 100644 --- a/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupListParamsTest.cs +++ b/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupListParamsTest.cs @@ -76,4 +76,14 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new DimensionalPriceGroupListParams { Cursor = "cursor", Limit = 1 }; + + DimensionalPriceGroupListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupRetrieveParamsTest.cs b/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupRetrieveParamsTest.cs index a66eb9aa..3a5879a7 100644 --- a/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupRetrieveParamsTest.cs +++ b/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupRetrieveParamsTest.cs @@ -35,4 +35,17 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new DimensionalPriceGroupRetrieveParams + { + DimensionalPriceGroupID = "dimensional_price_group_id", + }; + + DimensionalPriceGroupRetrieveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupUpdateParamsTest.cs b/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupUpdateParamsTest.cs index aa19e39c..6155b264 100644 --- a/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupUpdateParamsTest.cs @@ -83,4 +83,19 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new DimensionalPriceGroupUpdateParams + { + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + DimensionalPriceGroupUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDRetrieveParamsTest.cs b/src/Orb.Tests/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDRetrieveParamsTest.cs index e46e4199..61a175a2 100644 --- a/src/Orb.Tests/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDRetrieveParamsTest.cs +++ b/src/Orb.Tests/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDRetrieveParamsTest.cs @@ -38,4 +38,17 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ExternalDimensionalPriceGroupIDRetrieveParams + { + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + + ExternalDimensionalPriceGroupIDRetrieveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDUpdateParamsTest.cs b/src/Orb.Tests/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDUpdateParamsTest.cs index 88f44fe3..c56185c7 100644 --- a/src/Orb.Tests/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDUpdateParamsTest.cs @@ -86,4 +86,19 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ExternalDimensionalPriceGroupIDUpdateParams + { + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + ExternalDimensionalPriceGroupIDValue = "external_dimensional_price_group_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + ExternalDimensionalPriceGroupIDUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Events/Backfills/BackfillCloseParamsTest.cs b/src/Orb.Tests/Models/Events/Backfills/BackfillCloseParamsTest.cs index f374f30b..3e7bd323 100644 --- a/src/Orb.Tests/Models/Events/Backfills/BackfillCloseParamsTest.cs +++ b/src/Orb.Tests/Models/Events/Backfills/BackfillCloseParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/events/backfills/backfill_id/close"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BackfillCloseParams { BackfillID = "backfill_id" }; + + BackfillCloseParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Events/Backfills/BackfillCreateParamsTest.cs b/src/Orb.Tests/Models/Events/Backfills/BackfillCreateParamsTest.cs index 8c2c0c2a..26e19420 100644 --- a/src/Orb.Tests/Models/Events/Backfills/BackfillCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Events/Backfills/BackfillCreateParamsTest.cs @@ -132,4 +132,23 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/events/backfills"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BackfillCreateParams + { + TimeframeEnd = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CloseTime = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomerID = "customer_id", + DeprecationFilter = "my_numeric_property > 100 AND my_other_property = 'bar'", + ExternalCustomerID = "external_customer_id", + ReplaceExistingEvents = true, + }; + + BackfillCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Events/Backfills/BackfillFetchParamsTest.cs b/src/Orb.Tests/Models/Events/Backfills/BackfillFetchParamsTest.cs index 1ff26646..b7129229 100644 --- a/src/Orb.Tests/Models/Events/Backfills/BackfillFetchParamsTest.cs +++ b/src/Orb.Tests/Models/Events/Backfills/BackfillFetchParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/events/backfills/backfill_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BackfillFetchParams { BackfillID = "backfill_id" }; + + BackfillFetchParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Events/Backfills/BackfillListParamsTest.cs b/src/Orb.Tests/Models/Events/Backfills/BackfillListParamsTest.cs index 3536b9c3..f6aed51e 100644 --- a/src/Orb.Tests/Models/Events/Backfills/BackfillListParamsTest.cs +++ b/src/Orb.Tests/Models/Events/Backfills/BackfillListParamsTest.cs @@ -76,4 +76,14 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BackfillListParams { Cursor = "cursor", Limit = 1 }; + + BackfillListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Events/Backfills/BackfillRevertParamsTest.cs b/src/Orb.Tests/Models/Events/Backfills/BackfillRevertParamsTest.cs index 159db037..6d481596 100644 --- a/src/Orb.Tests/Models/Events/Backfills/BackfillRevertParamsTest.cs +++ b/src/Orb.Tests/Models/Events/Backfills/BackfillRevertParamsTest.cs @@ -27,4 +27,14 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BackfillRevertParams { BackfillID = "backfill_id" }; + + BackfillRevertParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Events/EventDeprecateParamsTest.cs b/src/Orb.Tests/Models/Events/EventDeprecateParamsTest.cs index f14fd39d..8a3fc8e8 100644 --- a/src/Orb.Tests/Models/Events/EventDeprecateParamsTest.cs +++ b/src/Orb.Tests/Models/Events/EventDeprecateParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/events/event_id/deprecate"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new EventDeprecateParams { EventID = "event_id" }; + + EventDeprecateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Events/EventIngestParamsTest.cs b/src/Orb.Tests/Models/Events/EventIngestParamsTest.cs index 09865dfd..10b90d67 100644 --- a/src/Orb.Tests/Models/Events/EventIngestParamsTest.cs +++ b/src/Orb.Tests/Models/Events/EventIngestParamsTest.cs @@ -203,6 +203,35 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new EventIngestParams + { + Events = + [ + new() + { + EventName = "event_name", + IdempotencyKey = "idempotency_key", + Properties = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Timestamp = DateTimeOffset.Parse("2020-12-09T16:09:53Z"), + CustomerID = "customer_id", + ExternalCustomerID = "external_customer_id", + }, + ], + BackfillID = "backfill_id", + Debug = true, + }; + + EventIngestParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class EventTest : TestBase diff --git a/src/Orb.Tests/Models/Events/EventSearchParamsTest.cs b/src/Orb.Tests/Models/Events/EventSearchParamsTest.cs index 32c0a7a9..bc3b222a 100644 --- a/src/Orb.Tests/Models/Events/EventSearchParamsTest.cs +++ b/src/Orb.Tests/Models/Events/EventSearchParamsTest.cs @@ -66,4 +66,19 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/events/search"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new EventSearchParams + { + EventIds = ["string"], + TimeframeEnd = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + EventSearchParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Events/EventUpdateParamsTest.cs b/src/Orb.Tests/Models/Events/EventUpdateParamsTest.cs index 481628c9..ef7056eb 100644 --- a/src/Orb.Tests/Models/Events/EventUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Events/EventUpdateParamsTest.cs @@ -108,4 +108,25 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/events/event_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new EventUpdateParams + { + EventID = "event_id", + EventName = "event_name", + Properties = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Timestamp = DateTimeOffset.Parse("2020-12-09T16:09:53Z"), + CustomerID = "customer_id", + ExternalCustomerID = "external_customer_id", + }; + + EventUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Events/Volume/VolumeListParamsTest.cs b/src/Orb.Tests/Models/Events/Volume/VolumeListParamsTest.cs index ef1c5f25..8f7ab9c8 100644 --- a/src/Orb.Tests/Models/Events/Volume/VolumeListParamsTest.cs +++ b/src/Orb.Tests/Models/Events/Volume/VolumeListParamsTest.cs @@ -111,4 +111,20 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new VolumeListParams + { + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Cursor = "cursor", + Limit = 1, + TimeframeEnd = DateTimeOffset.Parse("2024-10-11T06:00:00Z"), + }; + + VolumeListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/InvoiceLineItems/InvoiceLineItemCreateParamsTest.cs b/src/Orb.Tests/Models/InvoiceLineItems/InvoiceLineItemCreateParamsTest.cs index 8822a16f..fe05cf32 100644 --- a/src/Orb.Tests/Models/InvoiceLineItems/InvoiceLineItemCreateParamsTest.cs +++ b/src/Orb.Tests/Models/InvoiceLineItems/InvoiceLineItemCreateParamsTest.cs @@ -91,4 +91,23 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/invoice_line_items"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new InvoiceLineItemCreateParams + { + Amount = "12.00", + EndDate = "2023-09-22", + InvoiceID = "4khy3nwzktxv7", + Quantity = 1, + StartDate = "2023-09-22", + ItemID = "4khy3nwzktxv7", + Name = "Item Name", + }; + + InvoiceLineItemCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Invoices/InvoiceCreateParamsTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceCreateParamsTest.cs index 30ca312f..8cca91c8 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceCreateParamsTest.cs @@ -3,8 +3,8 @@ using System.Text.Json; using Orb.Core; using Orb.Exceptions; -using Orb.Models; -using Invoices = Orb.Models.Invoices; +using Orb.Models.Invoices; +using Models = Orb.Models; namespace Orb.Tests.Models.Invoices; @@ -13,7 +13,7 @@ public class InvoiceCreateParamsTest : TestBase [Fact] public void FieldRoundtrip_Works() { - var parameters = new Invoices::InvoiceCreateParams + var parameters = new InvoiceCreateParams { Currency = "USD", InvoiceDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), @@ -23,7 +23,7 @@ public void FieldRoundtrip_Works() { EndDate = "2023-09-22", ItemID = "4khy3nwzktxv7", - ModelType = Invoices::ModelType.Unit, + ModelType = ModelType.Unit, Name = "Line Item Name", Quantity = 1, StartDate = "2023-09-22", @@ -31,17 +31,17 @@ public void FieldRoundtrip_Works() }, ], CustomerID = "4khy3nwzktxv7", - Discount = new PercentageDiscount() + Discount = new Models::PercentageDiscount() { - DiscountType = PercentageDiscountDiscountType.Percentage, + DiscountType = Models::PercentageDiscountDiscountType.Percentage, PercentageDiscountValue = 0.15, AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], Filters = [ new() { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, + Field = Models::PercentageDiscountFilterField.PriceID, + Operator = Models::PercentageDiscountFilterOperator.Includes, Values = ["string"], }, ], @@ -57,13 +57,13 @@ public void FieldRoundtrip_Works() string expectedCurrency = "USD"; DateTimeOffset expectedInvoiceDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - List expectedLineItems = + List expectedLineItems = [ new() { EndDate = "2023-09-22", ItemID = "4khy3nwzktxv7", - ModelType = Invoices::ModelType.Unit, + ModelType = ModelType.Unit, Name = "Line Item Name", Quantity = 1, StartDate = "2023-09-22", @@ -71,23 +71,23 @@ public void FieldRoundtrip_Works() }, ]; string expectedCustomerID = "4khy3nwzktxv7"; - SharedDiscount expectedDiscount = new PercentageDiscount() + Models::SharedDiscount expectedDiscount = new Models::PercentageDiscount() { - DiscountType = PercentageDiscountDiscountType.Percentage, + DiscountType = Models::PercentageDiscountDiscountType.Percentage, PercentageDiscountValue = 0.15, AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], Filters = [ new() { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, + Field = Models::PercentageDiscountFilterField.PriceID, + Operator = Models::PercentageDiscountFilterOperator.Includes, Values = ["string"], }, ], Reason = "reason", }; - Invoices::DueDate expectedDueDate = "2023-09-22"; + DueDate expectedDueDate = "2023-09-22"; string expectedExternalCustomerID = "external-customer-id"; string expectedMemo = "An optional memo for my invoice."; Dictionary expectedMetadata = new() { { "foo", "string" } }; @@ -121,7 +121,7 @@ public void FieldRoundtrip_Works() [Fact] public void OptionalNonNullableParamsUnsetAreNotSet_Works() { - var parameters = new Invoices::InvoiceCreateParams + var parameters = new InvoiceCreateParams { Currency = "USD", InvoiceDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), @@ -131,7 +131,7 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() { EndDate = "2023-09-22", ItemID = "4khy3nwzktxv7", - ModelType = Invoices::ModelType.Unit, + ModelType = ModelType.Unit, Name = "Line Item Name", Quantity = 1, StartDate = "2023-09-22", @@ -139,17 +139,17 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() }, ], CustomerID = "4khy3nwzktxv7", - Discount = new PercentageDiscount() + Discount = new Models::PercentageDiscount() { - DiscountType = PercentageDiscountDiscountType.Percentage, + DiscountType = Models::PercentageDiscountDiscountType.Percentage, PercentageDiscountValue = 0.15, AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], Filters = [ new() { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, + Field = Models::PercentageDiscountFilterField.PriceID, + Operator = Models::PercentageDiscountFilterOperator.Includes, Values = ["string"], }, ], @@ -169,7 +169,7 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() [Fact] public void OptionalNonNullableParamsSetToNullAreNotSet_Works() { - var parameters = new Invoices::InvoiceCreateParams + var parameters = new InvoiceCreateParams { Currency = "USD", InvoiceDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), @@ -179,7 +179,7 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() { EndDate = "2023-09-22", ItemID = "4khy3nwzktxv7", - ModelType = Invoices::ModelType.Unit, + ModelType = ModelType.Unit, Name = "Line Item Name", Quantity = 1, StartDate = "2023-09-22", @@ -187,17 +187,17 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() }, ], CustomerID = "4khy3nwzktxv7", - Discount = new PercentageDiscount() + Discount = new Models::PercentageDiscount() { - DiscountType = PercentageDiscountDiscountType.Percentage, + DiscountType = Models::PercentageDiscountDiscountType.Percentage, PercentageDiscountValue = 0.15, AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], Filters = [ new() { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, + Field = Models::PercentageDiscountFilterField.PriceID, + Operator = Models::PercentageDiscountFilterOperator.Includes, Values = ["string"], }, ], @@ -220,7 +220,7 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() [Fact] public void OptionalNullableParamsUnsetAreNotSet_Works() { - var parameters = new Invoices::InvoiceCreateParams + var parameters = new InvoiceCreateParams { Currency = "USD", InvoiceDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), @@ -230,7 +230,7 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() { EndDate = "2023-09-22", ItemID = "4khy3nwzktxv7", - ModelType = Invoices::ModelType.Unit, + ModelType = ModelType.Unit, Name = "Line Item Name", Quantity = 1, StartDate = "2023-09-22", @@ -259,7 +259,7 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() [Fact] public void OptionalNullableParamsSetToNullAreSetToNull_Works() { - var parameters = new Invoices::InvoiceCreateParams + var parameters = new InvoiceCreateParams { Currency = "USD", InvoiceDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), @@ -269,7 +269,7 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() { EndDate = "2023-09-22", ItemID = "4khy3nwzktxv7", - ModelType = Invoices::ModelType.Unit, + ModelType = ModelType.Unit, Name = "Line Item Name", Quantity = 1, StartDate = "2023-09-22", @@ -306,7 +306,7 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() [Fact] public void Url_Works() { - Invoices::InvoiceCreateParams parameters = new() + InvoiceCreateParams parameters = new() { Currency = "USD", InvoiceDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), @@ -316,7 +316,7 @@ public void Url_Works() { EndDate = "2023-09-22", ItemID = "4khy3nwzktxv7", - ModelType = Invoices::ModelType.Unit, + ModelType = ModelType.Unit, Name = "Line Item Name", Quantity = 1, StartDate = "2023-09-22", @@ -329,6 +329,56 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/invoices"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new InvoiceCreateParams + { + Currency = "USD", + InvoiceDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + LineItems = + [ + new() + { + EndDate = "2023-09-22", + ItemID = "4khy3nwzktxv7", + ModelType = ModelType.Unit, + Name = "Line Item Name", + Quantity = 1, + StartDate = "2023-09-22", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + }, + ], + CustomerID = "4khy3nwzktxv7", + Discount = new Models::PercentageDiscount() + { + DiscountType = Models::PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = Models::PercentageDiscountFilterField.PriceID, + Operator = Models::PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + DueDate = "2023-09-22", + ExternalCustomerID = "external-customer-id", + Memo = "An optional memo for my invoice.", + Metadata = new Dictionary() { { "foo", "string" } }, + NetTerms = 0, + WillAutoIssue = false, + }; + + InvoiceCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class LineItemTest : TestBase @@ -336,11 +386,11 @@ public class LineItemTest : TestBase [Fact] public void FieldRoundtrip_Works() { - var model = new Invoices::LineItem + var model = new LineItem { EndDate = "2023-09-22", ItemID = "4khy3nwzktxv7", - ModelType = Invoices::ModelType.Unit, + ModelType = ModelType.Unit, Name = "Line Item Name", Quantity = 1, StartDate = "2023-09-22", @@ -349,11 +399,15 @@ public void FieldRoundtrip_Works() string expectedEndDate = "2023-09-22"; string expectedItemID = "4khy3nwzktxv7"; - ApiEnum expectedModelType = Invoices::ModelType.Unit; + ApiEnum expectedModelType = ModelType.Unit; string expectedName = "Line Item Name"; double expectedQuantity = 1; string expectedStartDate = "2023-09-22"; - UnitConfig expectedUnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }; + Models::UnitConfig expectedUnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }; Assert.Equal(expectedEndDate, model.EndDate); Assert.Equal(expectedItemID, model.ItemID); @@ -367,11 +421,11 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Invoices::LineItem + var model = new LineItem { EndDate = "2023-09-22", ItemID = "4khy3nwzktxv7", - ModelType = Invoices::ModelType.Unit, + ModelType = ModelType.Unit, Name = "Line Item Name", Quantity = 1, StartDate = "2023-09-22", @@ -379,10 +433,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); Assert.Equal(model, deserialized); } @@ -390,11 +441,11 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Invoices::LineItem + var model = new LineItem { EndDate = "2023-09-22", ItemID = "4khy3nwzktxv7", - ModelType = Invoices::ModelType.Unit, + ModelType = ModelType.Unit, Name = "Line Item Name", Quantity = 1, StartDate = "2023-09-22", @@ -402,7 +453,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -410,11 +461,15 @@ public void FieldRoundtripThroughSerialization_Works() string expectedEndDate = "2023-09-22"; string expectedItemID = "4khy3nwzktxv7"; - ApiEnum expectedModelType = Invoices::ModelType.Unit; + ApiEnum expectedModelType = ModelType.Unit; string expectedName = "Line Item Name"; double expectedQuantity = 1; string expectedStartDate = "2023-09-22"; - UnitConfig expectedUnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }; + Models::UnitConfig expectedUnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }; Assert.Equal(expectedEndDate, deserialized.EndDate); Assert.Equal(expectedItemID, deserialized.ItemID); @@ -428,11 +483,11 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Invoices::LineItem + var model = new LineItem { EndDate = "2023-09-22", ItemID = "4khy3nwzktxv7", - ModelType = Invoices::ModelType.Unit, + ModelType = ModelType.Unit, Name = "Line Item Name", Quantity = 1, StartDate = "2023-09-22", @@ -446,18 +501,18 @@ public void Validation_Works() public class ModelTypeTest : TestBase { [Theory] - [InlineData(Invoices::ModelType.Unit)] - public void Validation_Works(Invoices::ModelType rawValue) + [InlineData(ModelType.Unit)] + public void Validation_Works(ModelType rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -467,14 +522,14 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(Invoices::ModelType.Unit)] - public void SerializationRoundtrip_Works(Invoices::ModelType rawValue) + [InlineData(ModelType.Unit)] + public void SerializationRoundtrip_Works(ModelType rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( json, ModelBase.SerializerOptions ); @@ -485,12 +540,12 @@ public void SerializationRoundtrip_Works(Invoices::ModelType rawValue) [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( json, ModelBase.SerializerOptions ); @@ -504,23 +559,23 @@ public class DueDateTest : TestBase [Fact] public void DateValidationWorks() { - Invoices::DueDate value = "2019-12-27"; + DueDate value = "2019-12-27"; value.Validate(); } [Fact] public void DateTimeValidationWorks() { - Invoices::DueDate value = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DueDate value = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); value.Validate(); } [Fact] public void DateSerializationRoundtripWorks() { - Invoices::DueDate value = "2019-12-27"; + DueDate value = "2019-12-27"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -531,9 +586,9 @@ public void DateSerializationRoundtripWorks() [Fact] public void DateTimeSerializationRoundtripWorks() { - Invoices::DueDate value = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DueDate value = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); diff --git a/src/Orb.Tests/Models/Invoices/InvoiceDeleteLineItemParamsTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceDeleteLineItemParamsTest.cs index 793a2da7..1eb1692e 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceDeleteLineItemParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceDeleteLineItemParamsTest.cs @@ -39,4 +39,18 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new InvoiceDeleteLineItemParams + { + InvoiceID = "invoice_id", + LineItemID = "line_item_id", + }; + + InvoiceDeleteLineItemParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Invoices/InvoiceFetchParamsTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceFetchParamsTest.cs index dce86935..2f2def2e 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceFetchParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceFetchParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/invoices/invoice_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new InvoiceFetchParams { InvoiceID = "invoice_id" }; + + InvoiceFetchParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Invoices/InvoiceFetchUpcomingParamsTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceFetchUpcomingParamsTest.cs index d6ae79ff..8ee1a0ed 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceFetchUpcomingParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceFetchUpcomingParamsTest.cs @@ -27,4 +27,14 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new InvoiceFetchUpcomingParams { SubscriptionID = "subscription_id" }; + + InvoiceFetchUpcomingParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Invoices/InvoiceIssueParamsTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceIssueParamsTest.cs index 1e0133e9..dcb8bd7e 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceIssueParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceIssueParamsTest.cs @@ -50,4 +50,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/invoices/invoice_id/issue"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new InvoiceIssueParams { InvoiceID = "invoice_id", Synchronous = true }; + + InvoiceIssueParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Invoices/InvoiceListParamsTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceListParamsTest.cs index bf970547..d8699ca2 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceListParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceListParamsTest.cs @@ -285,6 +285,37 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new InvoiceListParams + { + Amount = "amount", + AmountGt = "amount[gt]", + AmountLt = "amount[lt]", + Cursor = "cursor", + CustomerID = "customer_id", + DateType = DateType.DueDate, + DueDate = "2019-12-27", + DueDateWindow = "due_date_window", + DueDateGt = "2019-12-27", + DueDateLt = "2019-12-27", + ExternalCustomerID = "external_customer_id", + InvoiceDateGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + InvoiceDateGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + InvoiceDateLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + InvoiceDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IsRecurring = true, + Limit = 1, + Status = [Status.Draft], + SubscriptionID = "subscription_id", + }; + + InvoiceListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class DateTypeTest : TestBase diff --git a/src/Orb.Tests/Models/Invoices/InvoiceListSummaryParamsTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceListSummaryParamsTest.cs index 60d01067..38f487e1 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceListSummaryParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceListSummaryParamsTest.cs @@ -31,8 +31,7 @@ public void FieldRoundtrip_Works() InvoiceDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), IsRecurring = true, Limit = 1, - Status = InvoiceListSummaryParamsStatus.Draft, - StatusValue = [StatusModel.Draft], + Status = [InvoiceListSummaryParamsStatus.Draft], SubscriptionID = "subscription_id", }; @@ -54,9 +53,10 @@ public void FieldRoundtrip_Works() DateTimeOffset expectedInvoiceDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); bool expectedIsRecurring = true; long expectedLimit = 1; - ApiEnum expectedStatus = - InvoiceListSummaryParamsStatus.Draft; - List> expectedStatusValue = [StatusModel.Draft]; + List> expectedStatus = + [ + InvoiceListSummaryParamsStatus.Draft, + ]; string expectedSubscriptionID = "subscription_id"; Assert.Equal(expectedAmount, parameters.Amount); @@ -76,12 +76,11 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedInvoiceDateLte, parameters.InvoiceDateLte); Assert.Equal(expectedIsRecurring, parameters.IsRecurring); Assert.Equal(expectedLimit, parameters.Limit); - Assert.Equal(expectedStatus, parameters.Status); - Assert.NotNull(parameters.StatusValue); - Assert.Equal(expectedStatusValue.Count, parameters.StatusValue.Count); - for (int i = 0; i < expectedStatusValue.Count; i++) + Assert.NotNull(parameters.Status); + Assert.Equal(expectedStatus.Count, parameters.Status.Count); + for (int i = 0; i < expectedStatus.Count; i++) { - Assert.Equal(expectedStatusValue[i], parameters.StatusValue[i]); + Assert.Equal(expectedStatus[i], parameters.Status[i]); } Assert.Equal(expectedSubscriptionID, parameters.SubscriptionID); } @@ -107,8 +106,7 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() InvoiceDateLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), InvoiceDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), IsRecurring = true, - Status = InvoiceListSummaryParamsStatus.Draft, - StatusValue = [StatusModel.Draft], + Status = [InvoiceListSummaryParamsStatus.Draft], SubscriptionID = "subscription_id", }; @@ -137,8 +135,7 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() InvoiceDateLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), InvoiceDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), IsRecurring = true, - Status = InvoiceListSummaryParamsStatus.Draft, - StatusValue = [StatusModel.Draft], + Status = [InvoiceListSummaryParamsStatus.Draft], SubscriptionID = "subscription_id", // Null should be interpreted as omitted for these properties @@ -188,8 +185,6 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() Assert.False(parameters.RawQueryData.ContainsKey("is_recurring")); Assert.Null(parameters.Status); Assert.False(parameters.RawQueryData.ContainsKey("status")); - Assert.Null(parameters.StatusValue); - Assert.False(parameters.RawQueryData.ContainsKey("status")); Assert.Null(parameters.SubscriptionID); Assert.False(parameters.RawQueryData.ContainsKey("subscription_id")); } @@ -218,7 +213,6 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() InvoiceDateLte = null, IsRecurring = null, Status = null, - StatusValue = null, SubscriptionID = null, }; @@ -256,8 +250,6 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() Assert.True(parameters.RawQueryData.ContainsKey("is_recurring")); Assert.Null(parameters.Status); Assert.True(parameters.RawQueryData.ContainsKey("status")); - Assert.Null(parameters.StatusValue); - Assert.True(parameters.RawQueryData.ContainsKey("status")); Assert.Null(parameters.SubscriptionID); Assert.True(parameters.RawQueryData.ContainsKey("subscription_id")); } @@ -284,8 +276,7 @@ public void Url_Works() InvoiceDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), IsRecurring = true, Limit = 1, - Status = null, - StatusValue = [StatusModel.Draft], + Status = [InvoiceListSummaryParamsStatus.Draft], SubscriptionID = "subscription_id", }; @@ -298,6 +289,37 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new InvoiceListSummaryParams + { + Amount = "amount", + AmountGt = "amount[gt]", + AmountLt = "amount[lt]", + Cursor = "cursor", + CustomerID = "customer_id", + DateType = InvoiceListSummaryParamsDateType.DueDate, + DueDate = "2019-12-27", + DueDateWindow = "due_date_window", + DueDateGt = "2019-12-27", + DueDateLt = "2019-12-27", + ExternalCustomerID = "external_customer_id", + InvoiceDateGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + InvoiceDateGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + InvoiceDateLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + InvoiceDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IsRecurring = true, + Limit = 1, + Status = [InvoiceListSummaryParamsStatus.Draft], + SubscriptionID = "subscription_id", + }; + + InvoiceListSummaryParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class InvoiceListSummaryParamsDateTypeTest : TestBase @@ -417,67 +439,3 @@ public void InvalidEnumSerializationRoundtrip_Works() Assert.Equal(value, deserialized); } } - -public class StatusModelTest : TestBase -{ - [Theory] - [InlineData(StatusModel.Draft)] - [InlineData(StatusModel.Issued)] - [InlineData(StatusModel.Paid)] - [InlineData(StatusModel.Synced)] - [InlineData(StatusModel.Void)] - public void Validation_Works(StatusModel rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(StatusModel.Draft)] - [InlineData(StatusModel.Issued)] - [InlineData(StatusModel.Paid)] - [InlineData(StatusModel.Synced)] - [InlineData(StatusModel.Void)] - public void SerializationRoundtrip_Works(StatusModel rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} diff --git a/src/Orb.Tests/Models/Invoices/InvoiceMarkPaidParamsTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceMarkPaidParamsTest.cs index d7664ee5..10361114 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceMarkPaidParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceMarkPaidParamsTest.cs @@ -73,4 +73,20 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/invoices/invoice_id/mark_paid"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new InvoiceMarkPaidParams + { + InvoiceID = "invoice_id", + PaymentReceivedDate = "2023-09-22", + ExternalID = "external_payment_id_123", + Notes = "notes", + }; + + InvoiceMarkPaidParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Invoices/InvoicePayParamsTest.cs b/src/Orb.Tests/Models/Invoices/InvoicePayParamsTest.cs index a79bf730..0b09b26f 100644 --- a/src/Orb.Tests/Models/Invoices/InvoicePayParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoicePayParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/invoices/invoice_id/pay"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new InvoicePayParams { InvoiceID = "invoice_id" }; + + InvoicePayParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Invoices/InvoiceUpdateParamsTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceUpdateParamsTest.cs index 91b236e2..b7ad75e4 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceUpdateParamsTest.cs @@ -87,6 +87,23 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/invoices/invoice_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new InvoiceUpdateParams + { + InvoiceID = "invoice_id", + DueDate = "2023-09-22", + InvoiceDate = "2023-09-22", + Metadata = new Dictionary() { { "foo", "string" } }, + NetTerms = 0, + }; + + InvoiceUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class InvoiceUpdateParamsDueDateTest : TestBase diff --git a/src/Orb.Tests/Models/Invoices/InvoiceVoidParamsTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceVoidParamsTest.cs index 9f4ff4f4..87d032b4 100644 --- a/src/Orb.Tests/Models/Invoices/InvoiceVoidParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoiceVoidParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/invoices/invoice_id/void"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new InvoiceVoidParams { InvoiceID = "invoice_id" }; + + InvoiceVoidParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Items/ItemArchiveParamsTest.cs b/src/Orb.Tests/Models/Items/ItemArchiveParamsTest.cs index e06cc416..324cc821 100644 --- a/src/Orb.Tests/Models/Items/ItemArchiveParamsTest.cs +++ b/src/Orb.Tests/Models/Items/ItemArchiveParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/items/item_id/archive"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ItemArchiveParams { ItemID = "item_id" }; + + ItemArchiveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Items/ItemCreateParamsTest.cs b/src/Orb.Tests/Models/Items/ItemCreateParamsTest.cs index ce453450..d663746c 100644 --- a/src/Orb.Tests/Models/Items/ItemCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Items/ItemCreateParamsTest.cs @@ -61,4 +61,18 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/items"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ItemCreateParams + { + Name = "API requests", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + ItemCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Items/ItemFetchParamsTest.cs b/src/Orb.Tests/Models/Items/ItemFetchParamsTest.cs index a3f2d620..b3e48dc1 100644 --- a/src/Orb.Tests/Models/Items/ItemFetchParamsTest.cs +++ b/src/Orb.Tests/Models/Items/ItemFetchParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/items/item_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ItemFetchParams { ItemID = "item_id" }; + + ItemFetchParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Items/ItemListParamsTest.cs b/src/Orb.Tests/Models/Items/ItemListParamsTest.cs index 20b1046a..0f395589 100644 --- a/src/Orb.Tests/Models/Items/ItemListParamsTest.cs +++ b/src/Orb.Tests/Models/Items/ItemListParamsTest.cs @@ -73,4 +73,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/items?cursor=cursor&limit=1"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ItemListParams { Cursor = "cursor", Limit = 1 }; + + ItemListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Items/ItemUpdateParamsTest.cs b/src/Orb.Tests/Models/Items/ItemUpdateParamsTest.cs index 8d3b688b..1def788e 100644 --- a/src/Orb.Tests/Models/Items/ItemUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Items/ItemUpdateParamsTest.cs @@ -99,6 +99,29 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/items/item_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ItemUpdateParams + { + ItemID = "item_id", + ExternalConnections = + [ + new() + { + ExternalConnectionName = ExternalConnectionName.Stripe, + ExternalEntityID = "external_entity_id", + }, + ], + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + }; + + ItemUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class ExternalConnectionTest : TestBase diff --git a/src/Orb.Tests/Models/Metrics/MetricCreateParamsTest.cs b/src/Orb.Tests/Models/Metrics/MetricCreateParamsTest.cs index 3bcadb99..6173d79c 100644 --- a/src/Orb.Tests/Models/Metrics/MetricCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Metrics/MetricCreateParamsTest.cs @@ -86,4 +86,21 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/metrics"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new MetricCreateParams + { + Description = "Sum of bytes downloaded in fast mode", + ItemID = "item_id", + Name = "Bytes downloaded", + Sql = "SELECT sum(bytes_downloaded) FROM events WHERE download_speed = 'fast'", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + MetricCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Metrics/MetricFetchParamsTest.cs b/src/Orb.Tests/Models/Metrics/MetricFetchParamsTest.cs index e0d5105e..9d69910d 100644 --- a/src/Orb.Tests/Models/Metrics/MetricFetchParamsTest.cs +++ b/src/Orb.Tests/Models/Metrics/MetricFetchParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/metrics/metric_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new MetricFetchParams { MetricID = "metric_id" }; + + MetricFetchParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Metrics/MetricListParamsTest.cs b/src/Orb.Tests/Models/Metrics/MetricListParamsTest.cs index 0b207e29..311c0cfd 100644 --- a/src/Orb.Tests/Models/Metrics/MetricListParamsTest.cs +++ b/src/Orb.Tests/Models/Metrics/MetricListParamsTest.cs @@ -133,4 +133,22 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new MetricListParams + { + CreatedAtGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAtGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAtLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAtLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Cursor = "cursor", + Limit = 1, + }; + + MetricListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Metrics/MetricUpdateParamsTest.cs b/src/Orb.Tests/Models/Metrics/MetricUpdateParamsTest.cs index 776ace1b..96c9499a 100644 --- a/src/Orb.Tests/Models/Metrics/MetricUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Metrics/MetricUpdateParamsTest.cs @@ -61,4 +61,18 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/metrics/metric_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new MetricUpdateParams + { + MetricID = "metric_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + MetricUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Plans/ExternalPlanID/ExternalPlanIDFetchParamsTest.cs b/src/Orb.Tests/Models/Plans/ExternalPlanID/ExternalPlanIDFetchParamsTest.cs index c8b71668..d6ccc6f9 100644 --- a/src/Orb.Tests/Models/Plans/ExternalPlanID/ExternalPlanIDFetchParamsTest.cs +++ b/src/Orb.Tests/Models/Plans/ExternalPlanID/ExternalPlanIDFetchParamsTest.cs @@ -27,4 +27,14 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ExternalPlanIDFetchParams { ExternalPlanID = "external_plan_id" }; + + ExternalPlanIDFetchParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Plans/ExternalPlanID/ExternalPlanIDUpdateParamsTest.cs b/src/Orb.Tests/Models/Plans/ExternalPlanID/ExternalPlanIDUpdateParamsTest.cs index 969cf7e5..24391069 100644 --- a/src/Orb.Tests/Models/Plans/ExternalPlanID/ExternalPlanIDUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Plans/ExternalPlanID/ExternalPlanIDUpdateParamsTest.cs @@ -75,4 +75,19 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ExternalPlanIDUpdateParams + { + OtherExternalPlanID = "external_plan_id", + ExternalPlanID = "external_plan_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + ExternalPlanIDUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Plans/Migrations/MigrationCancelParamsTest.cs b/src/Orb.Tests/Models/Plans/Migrations/MigrationCancelParamsTest.cs index fe1d3adc..c62a7c6f 100644 --- a/src/Orb.Tests/Models/Plans/Migrations/MigrationCancelParamsTest.cs +++ b/src/Orb.Tests/Models/Plans/Migrations/MigrationCancelParamsTest.cs @@ -37,4 +37,18 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new MigrationCancelParams + { + PlanID = "plan_id", + MigrationID = "migration_id", + }; + + MigrationCancelParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Plans/Migrations/MigrationListParamsTest.cs b/src/Orb.Tests/Models/Plans/Migrations/MigrationListParamsTest.cs index 52ca2129..9cb3a561 100644 --- a/src/Orb.Tests/Models/Plans/Migrations/MigrationListParamsTest.cs +++ b/src/Orb.Tests/Models/Plans/Migrations/MigrationListParamsTest.cs @@ -90,4 +90,19 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new MigrationListParams + { + PlanID = "plan_id", + Cursor = "cursor", + Limit = 1, + }; + + MigrationListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Plans/Migrations/MigrationRetrieveParamsTest.cs b/src/Orb.Tests/Models/Plans/Migrations/MigrationRetrieveParamsTest.cs index df81607a..0b2d915a 100644 --- a/src/Orb.Tests/Models/Plans/Migrations/MigrationRetrieveParamsTest.cs +++ b/src/Orb.Tests/Models/Plans/Migrations/MigrationRetrieveParamsTest.cs @@ -37,4 +37,18 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new MigrationRetrieveParams + { + PlanID = "plan_id", + MigrationID = "migration_id", + }; + + MigrationRetrieveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs b/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs index 0ff196c7..a68a107f 100644 --- a/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs @@ -804,6 +804,132 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/plans"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new PlanCreateParams + { + Currency = "currency", + Name = "name", + Prices = + [ + new() + { + AllocationPrice = new() + { + Amount = "10.00", + Cadence = Models::Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = Models::CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = Models::NewAllocationPriceFilterField.ItemID, + Operator = Models::NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + PlanPhaseOrder = 0, + PriceValue = new Models::NewPlanUnitPrice() + { + Cadence = Models::NewPlanUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + }, + ], + Adjustments = + [ + new() + { + AdjustmentValue = new Models::NewPercentageDiscount() + { + AdjustmentType = + Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = Models::NewPercentageDiscountFilterField.PriceID, + Operator = Models::NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = Models::NewPercentageDiscountPriceType.Usage, + }, + PlanPhaseOrder = 0, + }, + ], + DefaultInvoiceMemo = "default_invoice_memo", + ExternalPlanID = "external_plan_id", + Metadata = new Dictionary() { { "foo", "string" } }, + NetTerms = 0, + PlanPhases = + [ + new() + { + Order = 0, + AlignBillingWithPhaseStartDate = true, + Duration = 1, + DurationUnit = DurationUnit.Daily, + }, + ], + Status = Status.Active, + }; + + PlanCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class PriceTest : TestBase @@ -2740,49 +2866,6 @@ public void CumulativeGroupedAllocationValidationWorks() value.Validate(); } - [Fact] - public void MinimumValidationWorks() - { - PricePrice value = new Minimum() - { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - [Fact] public void NewPlanMinimumCompositeValidationWorks() { @@ -4534,55 +4617,6 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Assert.Equal(value, deserialized); } - [Fact] - public void MinimumSerializationRoundtripWorks() - { - PricePrice value = new Minimum() - { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - [Fact] public void NewPlanMinimumCompositeSerializationRoundtripWorks() { @@ -7951,707 +7985,6 @@ public void TieredSerializationRoundtripWorks() } } -public class MinimumTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new Minimum - { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - - ApiEnum expectedCadence = MinimumCadence.Annual; - string expectedItemID = "item_id"; - MinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - MinimumConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedItemID, model.ItemID); - Assert.Equal(expectedMinimumConfig, model.MinimumConfig); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); - Assert.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new Minimum - { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new Minimum - { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - ApiEnum expectedCadence = MinimumCadence.Annual; - string expectedItemID = "item_id"; - MinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - MinimumConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.Equal(expectedMinimumConfig, deserialized.MinimumConfig); - Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); - } - - [Fact] - public void Validation_Works() - { - var model = new Minimum - { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new Minimum - { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - }; - - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.False(model.RawData.ContainsKey("reference_id")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new Minimum - { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new Minimum - { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; - - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.True(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.True(model.RawData.ContainsKey("reference_id")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new Minimum - { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; - - model.Validate(); - } -} - -public class MinimumCadenceTest : TestBase -{ - [Theory] - [InlineData(MinimumCadence.Annual)] - [InlineData(MinimumCadence.SemiAnnual)] - [InlineData(MinimumCadence.Monthly)] - [InlineData(MinimumCadence.Quarterly)] - [InlineData(MinimumCadence.OneTime)] - [InlineData(MinimumCadence.Custom)] - public void Validation_Works(MinimumCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(MinimumCadence.Annual)] - [InlineData(MinimumCadence.SemiAnnual)] - [InlineData(MinimumCadence.Monthly)] - [InlineData(MinimumCadence.Quarterly)] - [InlineData(MinimumCadence.OneTime)] - [InlineData(MinimumCadence.Custom)] - public void SerializationRoundtrip_Works(MinimumCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - -public class MinimumConfigTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; - - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; - - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; - - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); - } - - [Fact] - public void Validation_Works() - { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() - { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() - { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() - { - var model = new MinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() - { - var model = new MinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; - - model.Validate(); - } -} - -public class MinimumConversionRateConfigTest : TestBase -{ - [Fact] - public void UnitValidationWorks() - { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() - { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); - } - - [Fact] - public void UnitSerializationRoundtripWorks() - { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void TieredSerializationRoundtripWorks() - { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - public class PercentTest : TestBase { [Fact] diff --git a/src/Orb.Tests/Models/Plans/PlanFetchParamsTest.cs b/src/Orb.Tests/Models/Plans/PlanFetchParamsTest.cs index a7bf5d80..7c0e0b10 100644 --- a/src/Orb.Tests/Models/Plans/PlanFetchParamsTest.cs +++ b/src/Orb.Tests/Models/Plans/PlanFetchParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/plans/plan_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new PlanFetchParams { PlanID = "plan_id" }; + + PlanFetchParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Plans/PlanListParamsTest.cs b/src/Orb.Tests/Models/Plans/PlanListParamsTest.cs index 9e211ee3..edd633d6 100644 --- a/src/Orb.Tests/Models/Plans/PlanListParamsTest.cs +++ b/src/Orb.Tests/Models/Plans/PlanListParamsTest.cs @@ -146,6 +146,25 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new PlanListParams + { + CreatedAtGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAtGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAtLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAtLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Cursor = "cursor", + Limit = 1, + Status = PlanListParamsStatus.Active, + }; + + PlanListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class PlanListParamsStatusTest : TestBase diff --git a/src/Orb.Tests/Models/Plans/PlanUpdateParamsTest.cs b/src/Orb.Tests/Models/Plans/PlanUpdateParamsTest.cs index 56911877..d6940400 100644 --- a/src/Orb.Tests/Models/Plans/PlanUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Plans/PlanUpdateParamsTest.cs @@ -69,4 +69,19 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/plans/plan_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new PlanUpdateParams + { + PlanID = "plan_id", + ExternalPlanID = "external_plan_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + PlanUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/PriceTest.cs b/src/Orb.Tests/Models/PriceTest.cs index f7a6bc8c..27aeec1c 100644 --- a/src/Orb.Tests/Models/PriceTest.cs +++ b/src/Orb.Tests/Models/PriceTest.cs @@ -3333,21 +3333,21 @@ public void CumulativeGroupedAllocationValidationWorks() } [Fact] - public void MinimumValidationWorks() + public void MinimumCompositeValidationWorks() { - Price value = new PriceMinimum() + Price value = new MinimumComposite() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PriceMinimumBillingMode.InAdvance, - Cadence = PriceMinimumCadence.OneTime, + BillingMode = MinimumCompositeBillingMode.InAdvance, + Cadence = MinimumCompositeCadence.OneTime, CompositePriceFilters = [ new() { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = MinimumCompositeCompositePriceFilterField.PriceID, + Operator = MinimumCompositeCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -3429,10 +3429,10 @@ public void MinimumValidationWorks() MinimumAmount = "minimum_amount", }, MinimumAmount = "minimum_amount", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "name", PlanPhaseOrder = 0, - PriceType = PriceMinimumPriceType.UsagePrice, + PriceType = MinimumCompositePriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = new() { @@ -3444,21 +3444,21 @@ public void MinimumValidationWorks() } [Fact] - public void MinimumCompositeValidationWorks() + public void PercentValidationWorks() { - Price value = new MinimumComposite() + Price value = new Percent() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MinimumCompositeBillingMode.InAdvance, - Cadence = MinimumCompositeCadence.OneTime, + BillingMode = PercentBillingMode.InAdvance, + Cadence = PercentCadence.OneTime, CompositePriceFilters = [ new() { - Field = MinimumCompositeCompositePriceFilterField.PriceID, - Operator = MinimumCompositeCompositePriceFilterOperator.Includes, + Field = PercentCompositePriceFilterField.PriceID, + Operator = PercentCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -3540,10 +3540,10 @@ public void MinimumCompositeValidationWorks() MinimumAmount = "minimum_amount", }, MinimumAmount = "minimum_amount", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "name", + PercentConfig = new(0), PlanPhaseOrder = 0, - PriceType = MinimumCompositePriceType.UsagePrice, + PriceType = PercentPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = new() { @@ -3555,21 +3555,21 @@ public void MinimumCompositeValidationWorks() } [Fact] - public void PercentValidationWorks() + public void EventOutputValidationWorks() { - Price value = new Percent() + Price value = new EventOutput() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PercentBillingMode.InAdvance, - Cadence = PercentCadence.OneTime, + BillingMode = EventOutputBillingMode.InAdvance, + Cadence = EventOutputCadence.OneTime, CompositePriceFilters = [ new() { - Field = PercentCompositePriceFilterField.PriceID, - Operator = PercentCompositePriceFilterOperator.Includes, + Field = EventOutputCompositePriceFilterField.PriceID, + Operator = EventOutputCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -3616,6 +3616,12 @@ public void PercentValidationWorks() ], Reason = "reason", }, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, @@ -3652,9 +3658,8 @@ public void PercentValidationWorks() }, MinimumAmount = "minimum_amount", Name = "name", - PercentConfig = new(0), PlanPhaseOrder = 0, - PriceType = PercentPriceType.UsagePrice, + PriceType = EventOutputPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = new() { @@ -3666,21 +3671,21 @@ public void PercentValidationWorks() } [Fact] - public void EventOutputValidationWorks() + public void UnitSerializationRoundtripWorks() { - Price value = new EventOutput() + Price value = new Unit() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = EventOutputBillingMode.InAdvance, - Cadence = EventOutputCadence.OneTime, + BillingMode = BillingMode.InAdvance, + Cadence = UnitCadence.OneTime, CompositePriceFilters = [ new() { - Field = EventOutputCompositePriceFilterField.PriceID, - Operator = EventOutputCompositePriceFilterOperator.Includes, + Field = CompositePriceFilterField.PriceID, + Operator = CompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -3727,12 +3732,6 @@ public void EventOutputValidationWorks() ], Reason = "reason", }, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, @@ -3770,33 +3769,37 @@ public void EventOutputValidationWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = EventOutputPriceType.UsagePrice, + PriceType = UnitPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, DimensionalPriceConfiguration = new() { DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); } [Fact] - public void UnitSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - Price value = new Unit() + Price value = new Tiered() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = BillingMode.InAdvance, - Cadence = UnitCadence.OneTime, + BillingMode = TieredBillingMode.InAdvance, + Cadence = TieredCadence.OneTime, CompositePriceFilters = [ new() { - Field = CompositePriceFilterField.PriceID, - Operator = CompositePriceFilterOperator.Includes, + Field = TieredCompositePriceFilterField.PriceID, + Operator = TieredCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -3880,9 +3883,21 @@ public void UnitSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = UnitPriceType.UsagePrice, + PriceType = TieredPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, DimensionalPriceConfiguration = new() { DimensionValues = ["string"], @@ -3896,21 +3911,22 @@ public void UnitSerializationRoundtripWorks() } [Fact] - public void TieredSerializationRoundtripWorks() + public void BulkSerializationRoundtripWorks() { - Price value = new Tiered() + Price value = new Bulk() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = TieredBillingMode.InAdvance, - Cadence = TieredCadence.OneTime, + BillingMode = BulkBillingMode.InAdvance, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = BulkCadence.OneTime, CompositePriceFilters = [ new() { - Field = TieredCompositePriceFilterField.PriceID, - Operator = TieredCompositePriceFilterOperator.Includes, + Field = BulkCompositePriceFilterField.PriceID, + Operator = BulkCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -3994,21 +4010,130 @@ public void TieredSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = TieredPriceType.UsagePrice, + PriceType = BulkPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - TieredConfig = new() + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BulkWithFiltersSerializationRoundtripWorks() + { + Price value = new BulkWithFilters() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = BulkWithFiltersBillingMode.InAdvance, + BulkWithFiltersConfig = new() { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = BulkWithFiltersCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = BulkWithFiltersCompositePriceFilterField.PriceID, + Operator = BulkWithFiltersCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditAllocation = new() + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + Filters = [ new() { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], }, ], - Prorated = true, }, + Currency = "currency", + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MaximumFilterField.PriceID, + Operator = MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MinimumFilterField.PriceID, + Operator = MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = BulkWithFiltersPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = new() { DimensionValues = ["string"], @@ -4022,22 +4147,21 @@ public void TieredSerializationRoundtripWorks() } [Fact] - public void BulkSerializationRoundtripWorks() + public void PackageSerializationRoundtripWorks() { - Price value = new Bulk() + Price value = new Package() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = BulkBillingMode.InAdvance, - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = BulkCadence.OneTime, + BillingMode = PackageBillingMode.InAdvance, + Cadence = PackageCadence.OneTime, CompositePriceFilters = [ new() { - Field = BulkCompositePriceFilterField.PriceID, - Operator = BulkCompositePriceFilterOperator.Includes, + Field = PackageCompositePriceFilterField.PriceID, + Operator = PackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -4120,8 +4244,9 @@ public void BulkSerializationRoundtripWorks() }, MinimumAmount = "minimum_amount", Name = "name", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, PlanPhaseOrder = 0, - PriceType = BulkPriceType.UsagePrice, + PriceType = PackagePriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = new() { @@ -4136,30 +4261,21 @@ public void BulkSerializationRoundtripWorks() } [Fact] - public void BulkWithFiltersSerializationRoundtripWorks() + public void MatrixSerializationRoundtripWorks() { - Price value = new BulkWithFilters() + Price value = new Matrix() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = BulkWithFiltersBillingMode.InAdvance, - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = BulkWithFiltersCadence.OneTime, + BillingMode = MatrixBillingMode.InAdvance, + Cadence = MatrixCadence.OneTime, CompositePriceFilters = [ new() { - Field = BulkWithFiltersCompositePriceFilterField.PriceID, - Operator = BulkWithFiltersCompositePriceFilterOperator.Includes, + Field = MatrixCompositePriceFilterField.PriceID, + Operator = MatrixCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -4210,6 +4326,12 @@ public void BulkWithFiltersSerializationRoundtripWorks() FixedPriceQuantity = 0, InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -4243,7 +4365,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = BulkWithFiltersPriceType.UsagePrice, + PriceType = MatrixPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = new() { @@ -4258,21 +4380,21 @@ public void BulkWithFiltersSerializationRoundtripWorks() } [Fact] - public void PackageSerializationRoundtripWorks() + public void ThresholdTotalAmountSerializationRoundtripWorks() { - Price value = new Package() + Price value = new ThresholdTotalAmount() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PackageBillingMode.InAdvance, - Cadence = PackageCadence.OneTime, + BillingMode = ThresholdTotalAmountBillingMode.InAdvance, + Cadence = ThresholdTotalAmountCadence.OneTime, CompositePriceFilters = [ new() { - Field = PackageCompositePriceFilterField.PriceID, - Operator = PackageCompositePriceFilterOperator.Includes, + Field = ThresholdTotalAmountCompositePriceFilterField.PriceID, + Operator = ThresholdTotalAmountCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -4355,10 +4477,18 @@ public void PackageSerializationRoundtripWorks() }, MinimumAmount = "minimum_amount", Name = "name", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, PlanPhaseOrder = 0, - PriceType = PackagePriceType.UsagePrice, + PriceType = ThresholdTotalAmountPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, DimensionalPriceConfiguration = new() { DimensionValues = ["string"], @@ -4372,21 +4502,21 @@ public void PackageSerializationRoundtripWorks() } [Fact] - public void MatrixSerializationRoundtripWorks() + public void TieredPackageSerializationRoundtripWorks() { - Price value = new Matrix() + Price value = new TieredPackage() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MatrixBillingMode.InAdvance, - Cadence = MatrixCadence.OneTime, + BillingMode = TieredPackageBillingMode.InAdvance, + Cadence = TieredPackageCadence.OneTime, CompositePriceFilters = [ new() { - Field = MatrixCompositePriceFilterField.PriceID, - Operator = MatrixCompositePriceFilterOperator.Includes, + Field = TieredPackageCompositePriceFilterField.PriceID, + Operator = TieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -4437,12 +4567,6 @@ public void MatrixSerializationRoundtripWorks() FixedPriceQuantity = 0, InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, - MatrixConfig = new() - { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], - }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -4476,8 +4600,17 @@ public void MatrixSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = MatrixPriceType.UsagePrice, + PriceType = TieredPackagePriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", + TieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, DimensionalPriceConfiguration = new() { DimensionValues = ["string"], @@ -4491,21 +4624,21 @@ public void MatrixSerializationRoundtripWorks() } [Fact] - public void ThresholdTotalAmountSerializationRoundtripWorks() + public void TieredWithMinimumSerializationRoundtripWorks() { - Price value = new ThresholdTotalAmount() + Price value = new TieredWithMinimum() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = ThresholdTotalAmountBillingMode.InAdvance, - Cadence = ThresholdTotalAmountCadence.OneTime, + BillingMode = TieredWithMinimumBillingMode.InAdvance, + Cadence = TieredWithMinimumCadence.OneTime, CompositePriceFilters = [ new() { - Field = ThresholdTotalAmountCompositePriceFilterField.PriceID, - Operator = ThresholdTotalAmountCompositePriceFilterOperator.Includes, + Field = TieredWithMinimumCompositePriceFilterField.PriceID, + Operator = TieredWithMinimumCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -4589,15 +4722,26 @@ public void ThresholdTotalAmountSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = ThresholdTotalAmountPriceType.UsagePrice, + PriceType = TieredWithMinimumPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - ThresholdTotalAmountConfig = new() + TieredWithMinimumConfig = new() { - ConsumptionTable = + Tiers = [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, ], + HideZeroAmountTiers = true, Prorate = true, }, DimensionalPriceConfiguration = new() @@ -4613,21 +4757,21 @@ public void ThresholdTotalAmountSerializationRoundtripWorks() } [Fact] - public void TieredPackageSerializationRoundtripWorks() + public void GroupedTieredSerializationRoundtripWorks() { - Price value = new TieredPackage() + Price value = new GroupedTiered() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = TieredPackageBillingMode.InAdvance, - Cadence = TieredPackageCadence.OneTime, + BillingMode = GroupedTieredBillingMode.InAdvance, + Cadence = GroupedTieredCadence.OneTime, CompositePriceFilters = [ new() { - Field = TieredPackageCompositePriceFilterField.PriceID, - Operator = TieredPackageCompositePriceFilterOperator.Includes, + Field = GroupedTieredCompositePriceFilterField.PriceID, + Operator = GroupedTieredCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -4676,6 +4820,15 @@ public void TieredPackageSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + GroupedTieredConfig = new() + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -4711,15 +4864,138 @@ public void TieredPackageSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = TieredPackagePriceType.UsagePrice, + PriceType = GroupedTieredPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - TieredPackageConfig = new() + DimensionalPriceConfiguration = new() { - PackageSize = "package_size", + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void TieredPackageWithMinimumSerializationRoundtripWorks() + { + Price value = new TieredPackageWithMinimum() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = TieredPackageWithMinimumBillingMode.InAdvance, + Cadence = TieredPackageWithMinimumCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = TieredPackageWithMinimumCompositePriceFilterField.PriceID, + Operator = TieredPackageWithMinimumCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditAllocation = new() + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MaximumFilterField.PriceID, + Operator = MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MinimumFilterField.PriceID, + Operator = MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = TieredPackageWithMinimumPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + TieredPackageWithMinimumConfig = new() + { + PackageSize = 0, Tiers = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, ], }, DimensionalPriceConfiguration = new() @@ -4735,21 +5011,21 @@ public void TieredPackageSerializationRoundtripWorks() } [Fact] - public void TieredWithMinimumSerializationRoundtripWorks() + public void PackageWithAllocationSerializationRoundtripWorks() { - Price value = new TieredWithMinimum() + Price value = new PackageWithAllocation() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = TieredWithMinimumBillingMode.InAdvance, - Cadence = TieredWithMinimumCadence.OneTime, + BillingMode = PackageWithAllocationBillingMode.InAdvance, + Cadence = PackageWithAllocationCadence.OneTime, CompositePriceFilters = [ new() { - Field = TieredWithMinimumCompositePriceFilterField.PriceID, - Operator = TieredWithMinimumCompositePriceFilterOperator.Includes, + Field = PackageWithAllocationCompositePriceFilterField.PriceID, + Operator = PackageWithAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -4832,150 +5108,14 @@ public void TieredWithMinimumSerializationRoundtripWorks() }, MinimumAmount = "minimum_amount", Name = "name", - PlanPhaseOrder = 0, - PriceType = TieredWithMinimumPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - TieredWithMinimumConfig = new() - { - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - HideZeroAmountTiers = true, - Prorate = true, - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - }, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void GroupedTieredSerializationRoundtripWorks() - { - Price value = new GroupedTiered() - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedTieredBillingMode.InAdvance, - Cadence = GroupedTieredCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = GroupedTieredCompositePriceFilterField.PriceID, - Operator = GroupedTieredCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() - { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], - }, - Currency = "currency", - Discount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - GroupedTieredConfig = new() - { - GroupingKey = "x", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - }, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() + PackageWithAllocationConfig = new() { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", }, - MinimumAmount = "minimum_amount", - Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedTieredPriceType.UsagePrice, + PriceType = PackageWithAllocationPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = new() { @@ -4990,21 +5130,21 @@ public void GroupedTieredSerializationRoundtripWorks() } [Fact] - public void TieredPackageWithMinimumSerializationRoundtripWorks() + public void UnitWithPercentSerializationRoundtripWorks() { - Price value = new TieredPackageWithMinimum() + Price value = new UnitWithPercent() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = TieredPackageWithMinimumBillingMode.InAdvance, - Cadence = TieredPackageWithMinimumCadence.OneTime, + BillingMode = UnitWithPercentBillingMode.InAdvance, + Cadence = UnitWithPercentCadence.OneTime, CompositePriceFilters = [ new() { - Field = TieredPackageWithMinimumCompositePriceFilterField.PriceID, - Operator = TieredPackageWithMinimumCompositePriceFilterOperator.Includes, + Field = UnitWithPercentCompositePriceFilterField.PriceID, + Operator = UnitWithPercentCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -5088,27 +5228,9 @@ public void TieredPackageWithMinimumSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = TieredPackageWithMinimumPriceType.UsagePrice, + PriceType = UnitWithPercentPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - TieredPackageWithMinimumConfig = new() - { - PackageSize = 0, - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - ], - }, + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, DimensionalPriceConfiguration = new() { DimensionValues = ["string"], @@ -5122,21 +5244,21 @@ public void TieredPackageWithMinimumSerializationRoundtripWorks() } [Fact] - public void PackageWithAllocationSerializationRoundtripWorks() + public void MatrixWithAllocationSerializationRoundtripWorks() { - Price value = new PackageWithAllocation() + Price value = new MatrixWithAllocation() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PackageWithAllocationBillingMode.InAdvance, - Cadence = PackageWithAllocationCadence.OneTime, + BillingMode = MatrixWithAllocationBillingMode.InAdvance, + Cadence = MatrixWithAllocationCadence.OneTime, CompositePriceFilters = [ new() { - Field = PackageWithAllocationCompositePriceFilterField.PriceID, - Operator = PackageWithAllocationCompositePriceFilterOperator.Includes, + Field = MatrixWithAllocationCompositePriceFilterField.PriceID, + Operator = MatrixWithAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -5187,6 +5309,13 @@ public void PackageWithAllocationSerializationRoundtripWorks() FixedPriceQuantity = 0, InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -5219,14 +5348,8 @@ public void PackageWithAllocationSerializationRoundtripWorks() }, MinimumAmount = "minimum_amount", Name = "name", - PackageWithAllocationConfig = new() - { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", - }, PlanPhaseOrder = 0, - PriceType = PackageWithAllocationPriceType.UsagePrice, + PriceType = MatrixWithAllocationPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = new() { @@ -5241,21 +5364,21 @@ public void PackageWithAllocationSerializationRoundtripWorks() } [Fact] - public void UnitWithPercentSerializationRoundtripWorks() + public void TieredWithProrationSerializationRoundtripWorks() { - Price value = new UnitWithPercent() + Price value = new TieredWithProration() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = UnitWithPercentBillingMode.InAdvance, - Cadence = UnitWithPercentCadence.OneTime, + BillingMode = TieredWithProrationBillingMode.InAdvance, + Cadence = TieredWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = UnitWithPercentCompositePriceFilterField.PriceID, - Operator = UnitWithPercentCompositePriceFilterOperator.Includes, + Field = TieredWithProrationCompositePriceFilterField.PriceID, + Operator = TieredWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -5339,9 +5462,11 @@ public void UnitWithPercentSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = UnitWithPercentPriceType.UsagePrice, + PriceType = TieredWithProrationPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), DimensionalPriceConfiguration = new() { DimensionValues = ["string"], @@ -5355,21 +5480,21 @@ public void UnitWithPercentSerializationRoundtripWorks() } [Fact] - public void MatrixWithAllocationSerializationRoundtripWorks() + public void UnitWithProrationSerializationRoundtripWorks() { - Price value = new MatrixWithAllocation() + Price value = new UnitWithProration() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MatrixWithAllocationBillingMode.InAdvance, - Cadence = MatrixWithAllocationCadence.OneTime, + BillingMode = UnitWithProrationBillingMode.InAdvance, + Cadence = UnitWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = MatrixWithAllocationCompositePriceFilterField.PriceID, - Operator = MatrixWithAllocationCompositePriceFilterOperator.Includes, + Field = UnitWithProrationCompositePriceFilterField.PriceID, + Operator = UnitWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -5420,13 +5545,6 @@ public void MatrixWithAllocationSerializationRoundtripWorks() FixedPriceQuantity = 0, InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, - MatrixWithAllocationConfig = new() - { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], - }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -5460,8 +5578,9 @@ public void MatrixWithAllocationSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = MatrixWithAllocationPriceType.UsagePrice, + PriceType = UnitWithProrationPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", + UnitWithProrationConfig = new("unit_amount"), DimensionalPriceConfiguration = new() { DimensionValues = ["string"], @@ -5475,21 +5594,21 @@ public void MatrixWithAllocationSerializationRoundtripWorks() } [Fact] - public void TieredWithProrationSerializationRoundtripWorks() + public void GroupedAllocationSerializationRoundtripWorks() { - Price value = new TieredWithProration() + Price value = new GroupedAllocation() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = TieredWithProrationBillingMode.InAdvance, - Cadence = TieredWithProrationCadence.OneTime, + BillingMode = GroupedAllocationBillingMode.InAdvance, + Cadence = GroupedAllocationCadence.OneTime, CompositePriceFilters = [ new() { - Field = TieredWithProrationCompositePriceFilterField.PriceID, - Operator = TieredWithProrationCompositePriceFilterOperator.Includes, + Field = GroupedAllocationCompositePriceFilterField.PriceID, + Operator = GroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -5538,6 +5657,12 @@ public void TieredWithProrationSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -5573,11 +5698,8 @@ public void TieredWithProrationSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = TieredWithProrationPriceType.UsagePrice, + PriceType = GroupedAllocationPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), DimensionalPriceConfiguration = new() { DimensionValues = ["string"], @@ -5591,21 +5713,27 @@ public void TieredWithProrationSerializationRoundtripWorks() } [Fact] - public void UnitWithProrationSerializationRoundtripWorks() + public void BulkWithProrationSerializationRoundtripWorks() { - Price value = new UnitWithProration() + Price value = new BulkWithProration() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = UnitWithProrationBillingMode.InAdvance, - Cadence = UnitWithProrationCadence.OneTime, + BillingMode = BulkWithProrationBillingMode.InAdvance, + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.OneTime, CompositePriceFilters = [ new() { - Field = UnitWithProrationCompositePriceFilterField.PriceID, - Operator = UnitWithProrationCompositePriceFilterOperator.Includes, + Field = BulkWithProrationCompositePriceFilterField.PriceID, + Operator = BulkWithProrationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -5689,9 +5817,8 @@ public void UnitWithProrationSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = UnitWithProrationPriceType.UsagePrice, + PriceType = BulkWithProrationPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - UnitWithProrationConfig = new("unit_amount"), DimensionalPriceConfiguration = new() { DimensionValues = ["string"], @@ -5705,21 +5832,21 @@ public void UnitWithProrationSerializationRoundtripWorks() } [Fact] - public void GroupedAllocationSerializationRoundtripWorks() + public void GroupedWithProratedMinimumSerializationRoundtripWorks() { - Price value = new GroupedAllocation() + Price value = new GroupedWithProratedMinimum() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedAllocationBillingMode.InAdvance, - Cadence = GroupedAllocationCadence.OneTime, + BillingMode = GroupedWithProratedMinimumBillingMode.InAdvance, + Cadence = GroupedWithProratedMinimumCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedAllocationCompositePriceFilterField.PriceID, - Operator = GroupedAllocationCompositePriceFilterOperator.Includes, + Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, + Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -5768,11 +5895,11 @@ public void GroupedAllocationSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedAllocationConfig = new() + GroupedWithProratedMinimumConfig = new() { - Allocation = "allocation", GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", + Minimum = "minimum", + UnitRate = "unit_rate", }, InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, @@ -5809,7 +5936,7 @@ public void GroupedAllocationSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedAllocationPriceType.UsagePrice, + PriceType = GroupedWithProratedMinimumPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = new() { @@ -5824,27 +5951,21 @@ public void GroupedAllocationSerializationRoundtripWorks() } [Fact] - public void BulkWithProrationSerializationRoundtripWorks() + public void GroupedWithMeteredMinimumSerializationRoundtripWorks() { - Price value = new BulkWithProration() + Price value = new GroupedWithMeteredMinimum() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = BulkWithProrationBillingMode.InAdvance, - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = BulkWithProrationCadence.OneTime, + BillingMode = GroupedWithMeteredMinimumBillingMode.InAdvance, + Cadence = GroupedWithMeteredMinimumCadence.OneTime, CompositePriceFilters = [ new() { - Field = BulkWithProrationCompositePriceFilterField.PriceID, - Operator = BulkWithProrationCompositePriceFilterOperator.Includes, + Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, + Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -5893,6 +6014,21 @@ public void BulkWithProrationSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, + GroupedWithMeteredMinimumConfig = new() + { + GroupingKey = "x", + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = + [ + new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, + ], + ScalingKey = "scaling_key", + UnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, + ], + }, InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -5928,7 +6064,7 @@ public void BulkWithProrationSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = BulkWithProrationPriceType.UsagePrice, + PriceType = GroupedWithMeteredMinimumPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = new() { @@ -5943,21 +6079,21 @@ public void BulkWithProrationSerializationRoundtripWorks() } [Fact] - public void GroupedWithProratedMinimumSerializationRoundtripWorks() + public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() { - Price value = new GroupedWithProratedMinimum() + Price value = new GroupedWithMinMaxThresholds() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithProratedMinimumBillingMode.InAdvance, - Cadence = GroupedWithProratedMinimumCadence.OneTime, + BillingMode = GroupedWithMinMaxThresholdsBillingMode.InAdvance, + Cadence = GroupedWithMinMaxThresholdsCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, + Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, + Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -6006,11 +6142,12 @@ public void GroupedWithProratedMinimumSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithProratedMinimumConfig = new() + GroupedWithMinMaxThresholdsConfig = new() { GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, @@ -6047,7 +6184,7 @@ public void GroupedWithProratedMinimumSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithProratedMinimumPriceType.UsagePrice, + PriceType = GroupedWithMinMaxThresholdsPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = new() { @@ -6062,21 +6199,21 @@ public void GroupedWithProratedMinimumSerializationRoundtripWorks() } [Fact] - public void GroupedWithMeteredMinimumSerializationRoundtripWorks() + public void MatrixWithDisplayNameSerializationRoundtripWorks() { - Price value = new GroupedWithMeteredMinimum() + Price value = new MatrixWithDisplayName() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithMeteredMinimumBillingMode.InAdvance, - Cadence = GroupedWithMeteredMinimumCadence.OneTime, + BillingMode = MatrixWithDisplayNameBillingMode.InAdvance, + Cadence = MatrixWithDisplayNameCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, + Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -6125,19 +6262,140 @@ public void GroupedWithMeteredMinimumSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithMeteredMinimumConfig = new() + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, + MatrixWithDisplayNameConfig = new() { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = + Dimension = "dimension", + UnitAmounts = [ - new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, ], - ScalingKey = "scaling_key", - UnitAmounts = + }, + Maximum = new() + { + AppliesToPriceIds = ["string"], + Filters = [ - new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, + new() + { + Field = MaximumFilterField.PriceID, + Operator = MaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + MaximumAmount = "maximum_amount", + }, + MaximumAmount = "maximum_amount", + Metadata = new Dictionary() { { "foo", "string" } }, + Minimum = new() + { + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = MinimumFilterField.PriceID, + Operator = MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", + }, + MinimumAmount = "minimum_amount", + Name = "name", + PlanPhaseOrder = 0, + PriceType = MatrixWithDisplayNamePriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void GroupedTieredPackageSerializationRoundtripWorks() + { + Price value = new GroupedTieredPackage() + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = GroupedTieredPackageBillingMode.InAdvance, + Cadence = GroupedTieredPackageCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = GroupedTieredPackageCompositePriceFilterField.PriceID, + Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditAllocation = new() + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + }, + Currency = "currency", + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + GroupedTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], }, InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, @@ -6175,7 +6433,7 @@ public void GroupedWithMeteredMinimumSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithMeteredMinimumPriceType.UsagePrice, + PriceType = GroupedTieredPackagePriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = new() { @@ -6190,21 +6448,21 @@ public void GroupedWithMeteredMinimumSerializationRoundtripWorks() } [Fact] - public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() + public void MaxGroupTieredPackageSerializationRoundtripWorks() { - Price value = new GroupedWithMinMaxThresholds() + Price value = new MaxGroupTieredPackage() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithMinMaxThresholdsBillingMode.InAdvance, - Cadence = GroupedWithMinMaxThresholdsCadence.OneTime, + BillingMode = MaxGroupTieredPackageBillingMode.InAdvance, + Cadence = MaxGroupTieredPackageCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, - Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, + Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, + Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -6253,15 +6511,18 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedWithMinMaxThresholdsConfig = new() + InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + Item = new() { ID = "id", Name = "name" }, + MaxGroupTieredPackageConfig = new() { GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], }, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -6295,7 +6556,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedWithMinMaxThresholdsPriceType.UsagePrice, + PriceType = MaxGroupTieredPackagePriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = new() { @@ -6310,21 +6571,21 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() } [Fact] - public void MatrixWithDisplayNameSerializationRoundtripWorks() + public void ScalableMatrixWithUnitPricingSerializationRoundtripWorks() { - Price value = new MatrixWithDisplayName() + Price value = new ScalableMatrixWithUnitPricing() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MatrixWithDisplayNameBillingMode.InAdvance, - Cadence = MatrixWithDisplayNameCadence.OneTime, + BillingMode = ScalableMatrixWithUnitPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithUnitPricingCadence.OneTime, CompositePriceFilters = [ new() { - Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, - Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -6375,19 +6636,6 @@ public void MatrixWithDisplayNameSerializationRoundtripWorks() FixedPriceQuantity = 0, InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, - MatrixWithDisplayNameConfig = new() - { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], - }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -6421,8 +6669,24 @@ public void MatrixWithDisplayNameSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = MatrixWithDisplayNamePriceType.UsagePrice, + PriceType = ScalableMatrixWithUnitPricingPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + Prorate = true, + SecondDimension = "second_dimension", + }, DimensionalPriceConfiguration = new() { DimensionValues = ["string"], @@ -6436,21 +6700,21 @@ public void MatrixWithDisplayNameSerializationRoundtripWorks() } [Fact] - public void GroupedTieredPackageSerializationRoundtripWorks() + public void ScalableMatrixWithTieredPricingSerializationRoundtripWorks() { - Price value = new GroupedTieredPackage() + Price value = new ScalableMatrixWithTieredPricing() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedTieredPackageBillingMode.InAdvance, - Cadence = GroupedTieredPackageCadence.OneTime, + BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, CompositePriceFilters = [ new() { - Field = GroupedTieredPackageCompositePriceFilterField.PriceID, - Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, + Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -6499,16 +6763,6 @@ public void GroupedTieredPackageSerializationRoundtripWorks() }, ExternalPriceID = "external_price_id", FixedPriceQuantity = 0, - GroupedTieredPackageConfig = new() - { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], - }, InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -6544,8 +6798,27 @@ public void GroupedTieredPackageSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = GroupedTieredPackagePriceType.UsagePrice, + PriceType = ScalableMatrixWithTieredPricingPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", + ScalableMatrixWithTieredPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + SecondDimension = "second_dimension", + }, DimensionalPriceConfiguration = new() { DimensionValues = ["string"], @@ -6559,21 +6832,21 @@ public void GroupedTieredPackageSerializationRoundtripWorks() } [Fact] - public void MaxGroupTieredPackageSerializationRoundtripWorks() + public void CumulativeGroupedBulkSerializationRoundtripWorks() { - Price value = new MaxGroupTieredPackage() + Price value = new CumulativeGroupedBulk() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MaxGroupTieredPackageBillingMode.InAdvance, - Cadence = MaxGroupTieredPackageCadence.OneTime, + BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, + Cadence = CumulativeGroupedBulkCadence.OneTime, CompositePriceFilters = [ new() { - Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, - Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -6603,6 +6876,19 @@ public void MaxGroupTieredPackageSerializationRoundtripWorks() }, ], }, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, Currency = "currency", Discount = new PercentageDiscount() { @@ -6624,16 +6910,6 @@ public void MaxGroupTieredPackageSerializationRoundtripWorks() FixedPriceQuantity = 0, InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, - MaxGroupTieredPackageConfig = new() - { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - }, Maximum = new() { AppliesToPriceIds = ["string"], @@ -6667,7 +6943,7 @@ public void MaxGroupTieredPackageSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = MaxGroupTieredPackagePriceType.UsagePrice, + PriceType = CumulativeGroupedBulkPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = new() { @@ -6682,21 +6958,21 @@ public void MaxGroupTieredPackageSerializationRoundtripWorks() } [Fact] - public void ScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void CumulativeGroupedAllocationSerializationRoundtripWorks() { - Price value = new ScalableMatrixWithUnitPricing() + Price value = new CumulativeGroupedAllocation() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = ScalableMatrixWithUnitPricingBillingMode.InAdvance, - Cadence = ScalableMatrixWithUnitPricingCadence.OneTime, + BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, + Cadence = CumulativeGroupedAllocationCadence.OneTime, CompositePriceFilters = [ new() { - Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -6726,6 +7002,13 @@ public void ScalableMatrixWithUnitPricingSerializationRoundtripWorks() }, ], }, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, Currency = "currency", Discount = new PercentageDiscount() { @@ -6780,24 +7063,8 @@ public void ScalableMatrixWithUnitPricingSerializationRoundtripWorks() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = ScalableMatrixWithUnitPricingPriceType.UsagePrice, + PriceType = CumulativeGroupedAllocationPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - ScalableMatrixWithUnitPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - UnitPrice = "unit_price", - Prorate = true, - SecondDimension = "second_dimension", - }, DimensionalPriceConfiguration = new() { DimensionValues = ["string"], @@ -6811,21 +7078,21 @@ public void ScalableMatrixWithUnitPricingSerializationRoundtripWorks() } [Fact] - public void ScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void MinimumCompositeSerializationRoundtripWorks() { - Price value = new ScalableMatrixWithTieredPricing() + Price value = new MinimumComposite() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, - Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, + BillingMode = MinimumCompositeBillingMode.InAdvance, + Cadence = MinimumCompositeCadence.OneTime, CompositePriceFilters = [ new() { - Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, - Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, + Field = MinimumCompositeCompositePriceFilterField.PriceID, + Operator = MinimumCompositeCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -6907,29 +7174,11 @@ public void ScalableMatrixWithTieredPricingSerializationRoundtripWorks() MinimumAmount = "minimum_amount", }, MinimumAmount = "minimum_amount", + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "name", PlanPhaseOrder = 0, - PriceType = ScalableMatrixWithTieredPricingPriceType.UsagePrice, + PriceType = MinimumCompositePriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - ScalableMatrixWithTieredPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - SecondDimension = "second_dimension", - }, DimensionalPriceConfiguration = new() { DimensionValues = ["string"], @@ -6943,21 +7192,21 @@ public void ScalableMatrixWithTieredPricingSerializationRoundtripWorks() } [Fact] - public void CumulativeGroupedBulkSerializationRoundtripWorks() + public void PercentSerializationRoundtripWorks() { - Price value = new CumulativeGroupedBulk() + Price value = new Percent() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, - Cadence = CumulativeGroupedBulkCadence.OneTime, + BillingMode = PercentBillingMode.InAdvance, + Cadence = PercentCadence.OneTime, CompositePriceFilters = [ new() { - Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, + Field = PercentCompositePriceFilterField.PriceID, + Operator = PercentCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -6987,19 +7236,6 @@ public void CumulativeGroupedBulkSerializationRoundtripWorks() }, ], }, - CumulativeGroupedBulkConfig = new() - { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", - }, Currency = "currency", Discount = new PercentageDiscount() { @@ -7053,8 +7289,9 @@ public void CumulativeGroupedBulkSerializationRoundtripWorks() }, MinimumAmount = "minimum_amount", Name = "name", + PercentConfig = new(0), PlanPhaseOrder = 0, - PriceType = CumulativeGroupedBulkPriceType.UsagePrice, + PriceType = PercentPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = new() { @@ -7069,483 +7306,21 @@ public void CumulativeGroupedBulkSerializationRoundtripWorks() } [Fact] - public void CumulativeGroupedAllocationSerializationRoundtripWorks() + public void EventOutputSerializationRoundtripWorks() { - Price value = new CumulativeGroupedAllocation() + Price value = new EventOutput() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, - Cadence = CumulativeGroupedAllocationCadence.OneTime, + BillingMode = EventOutputBillingMode.InAdvance, + Cadence = EventOutputCadence.OneTime, CompositePriceFilters = [ new() { - Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() - { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], - }, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - Currency = "currency", - Discount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", - }, - MinimumAmount = "minimum_amount", - Name = "name", - PlanPhaseOrder = 0, - PriceType = CumulativeGroupedAllocationPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - }, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void MinimumSerializationRoundtripWorks() - { - Price value = new PriceMinimum() - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PriceMinimumBillingMode.InAdvance, - Cadence = PriceMinimumCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() - { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], - }, - Currency = "currency", - Discount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", - }, - MinimumAmount = "minimum_amount", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "name", - PlanPhaseOrder = 0, - PriceType = PriceMinimumPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - }, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void MinimumCompositeSerializationRoundtripWorks() - { - Price value = new MinimumComposite() - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MinimumCompositeBillingMode.InAdvance, - Cadence = MinimumCompositeCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = MinimumCompositeCompositePriceFilterField.PriceID, - Operator = MinimumCompositeCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() - { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], - }, - Currency = "currency", - Discount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", - }, - MinimumAmount = "minimum_amount", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "name", - PlanPhaseOrder = 0, - PriceType = MinimumCompositePriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - }, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void PercentSerializationRoundtripWorks() - { - Price value = new Percent() - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PercentBillingMode.InAdvance, - Cadence = PercentCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = PercentCompositePriceFilterField.PriceID, - Operator = PercentCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() - { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], - }, - Currency = "currency", - Discount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", - }, - MinimumAmount = "minimum_amount", - Name = "name", - PercentConfig = new(0), - PlanPhaseOrder = 0, - PriceType = PercentPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - }, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void EventOutputSerializationRoundtripWorks() - { - Price value = new EventOutput() - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = EventOutputBillingMode.InAdvance, - Cadence = EventOutputCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = EventOutputCompositePriceFilterField.PriceID, - Operator = EventOutputCompositePriceFilterOperator.Includes, + Field = EventOutputCompositePriceFilterField.PriceID, + Operator = EventOutputCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -60274,1793 +60049,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() MinimumAmount = "minimum_amount", Name = "name", PlanPhaseOrder = 0, - PriceType = CumulativeGroupedAllocationPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - }; - - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new CumulativeGroupedAllocation - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, - Cadence = CumulativeGroupedAllocationCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() - { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], - }, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - Currency = "currency", - Discount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", - }, - MinimumAmount = "minimum_amount", - Name = "name", - PlanPhaseOrder = 0, - PriceType = CumulativeGroupedAllocationPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new CumulativeGroupedAllocation - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, - Cadence = CumulativeGroupedAllocationCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() - { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], - }, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - Currency = "currency", - Discount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", - }, - MinimumAmount = "minimum_amount", - Name = "name", - PlanPhaseOrder = 0, - PriceType = CumulativeGroupedAllocationPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - - DimensionalPriceConfiguration = null, - }; - - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new CumulativeGroupedAllocation - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, - Cadence = CumulativeGroupedAllocationCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() - { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], - }, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - Currency = "currency", - Discount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", - }, - MinimumAmount = "minimum_amount", - Name = "name", - PlanPhaseOrder = 0, - PriceType = CumulativeGroupedAllocationPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - - DimensionalPriceConfiguration = null, - }; - - model.Validate(); - } -} - -public class CumulativeGroupedAllocationBillingModeTest : TestBase -{ - [Theory] - [InlineData(CumulativeGroupedAllocationBillingMode.InAdvance)] - [InlineData(CumulativeGroupedAllocationBillingMode.InArrear)] - public void Validation_Works(CumulativeGroupedAllocationBillingMode rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(CumulativeGroupedAllocationBillingMode.InAdvance)] - [InlineData(CumulativeGroupedAllocationBillingMode.InArrear)] - public void SerializationRoundtrip_Works(CumulativeGroupedAllocationBillingMode rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } -} - -public class CumulativeGroupedAllocationCadenceTest : TestBase -{ - [Theory] - [InlineData(CumulativeGroupedAllocationCadence.OneTime)] - [InlineData(CumulativeGroupedAllocationCadence.Monthly)] - [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(CumulativeGroupedAllocationCadence.Annual)] - [InlineData(CumulativeGroupedAllocationCadence.Custom)] - public void Validation_Works(CumulativeGroupedAllocationCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(CumulativeGroupedAllocationCadence.OneTime)] - [InlineData(CumulativeGroupedAllocationCadence.Monthly)] - [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(CumulativeGroupedAllocationCadence.Annual)] - [InlineData(CumulativeGroupedAllocationCadence.Custom)] - public void SerializationRoundtrip_Works(CumulativeGroupedAllocationCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } -} - -public class CumulativeGroupedAllocationCompositePriceFilterTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new CumulativeGroupedAllocationCompositePriceFilter - { - Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, - Values = ["string"], - }; - - ApiEnum expectedField = - CumulativeGroupedAllocationCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - CumulativeGroupedAllocationCompositePriceFilterOperator.Includes; - List expectedValues = ["string"]; - - Assert.Equal(expectedField, model.Field); - Assert.Equal(expectedOperator, model.Operator); - Assert.Equal(expectedValues.Count, model.Values.Count); - for (int i = 0; i < expectedValues.Count; i++) - { - Assert.Equal(expectedValues[i], model.Values[i]); - } - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new CumulativeGroupedAllocationCompositePriceFilter - { - Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, - Values = ["string"], - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new CumulativeGroupedAllocationCompositePriceFilter - { - Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, - Values = ["string"], - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - ApiEnum expectedField = - CumulativeGroupedAllocationCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - CumulativeGroupedAllocationCompositePriceFilterOperator.Includes; - List expectedValues = ["string"]; - - Assert.Equal(expectedField, deserialized.Field); - Assert.Equal(expectedOperator, deserialized.Operator); - Assert.Equal(expectedValues.Count, deserialized.Values.Count); - for (int i = 0; i < expectedValues.Count; i++) - { - Assert.Equal(expectedValues[i], deserialized.Values[i]); - } - } - - [Fact] - public void Validation_Works() - { - var model = new CumulativeGroupedAllocationCompositePriceFilter - { - Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, - Values = ["string"], - }; - - model.Validate(); - } -} - -public class CumulativeGroupedAllocationCompositePriceFilterFieldTest : TestBase -{ - [Theory] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.PriceID)] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.ItemID)] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.PriceType)] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.Currency)] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.PricingUnitID)] - public void Validation_Works(CumulativeGroupedAllocationCompositePriceFilterField rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.PriceID)] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.ItemID)] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.PriceType)] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.Currency)] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.PricingUnitID)] - public void SerializationRoundtrip_Works( - CumulativeGroupedAllocationCompositePriceFilterField rawValue - ) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } -} - -public class CumulativeGroupedAllocationCompositePriceFilterOperatorTest : TestBase -{ - [Theory] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterOperator.Includes)] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterOperator.Excludes)] - public void Validation_Works(CumulativeGroupedAllocationCompositePriceFilterOperator rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterOperator.Includes)] - [InlineData(CumulativeGroupedAllocationCompositePriceFilterOperator.Excludes)] - public void SerializationRoundtrip_Works( - CumulativeGroupedAllocationCompositePriceFilterOperator rawValue - ) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } -} - -public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase -{ - [Fact] - public void UnitValidationWorks() - { - CumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() - { - CumulativeGroupedAllocationConversionRateConfig value = - new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); - } - - [Fact] - public void UnitSerializationRoundtripWorks() - { - CumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void TieredSerializationRoundtripWorks() - { - CumulativeGroupedAllocationConversionRateConfig value = - new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - -public class CumulativeGroupedAllocationConfigTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new CumulativeGroupedAllocationConfig - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; - - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; - - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedUnitAmount, model.UnitAmount); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new CumulativeGroupedAllocationConfig - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new CumulativeGroupedAllocationConfig - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; - - Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); - } - - [Fact] - public void Validation_Works() - { - var model = new CumulativeGroupedAllocationConfig - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; - - model.Validate(); - } -} - -public class CumulativeGroupedAllocationPriceTypeTest : TestBase -{ - [Theory] - [InlineData(CumulativeGroupedAllocationPriceType.UsagePrice)] - [InlineData(CumulativeGroupedAllocationPriceType.FixedPrice)] - [InlineData(CumulativeGroupedAllocationPriceType.CompositePrice)] - public void Validation_Works(CumulativeGroupedAllocationPriceType rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(CumulativeGroupedAllocationPriceType.UsagePrice)] - [InlineData(CumulativeGroupedAllocationPriceType.FixedPrice)] - [InlineData(CumulativeGroupedAllocationPriceType.CompositePrice)] - public void SerializationRoundtrip_Works(CumulativeGroupedAllocationPriceType rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } -} - -public class PriceMinimumTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new PriceMinimum - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PriceMinimumBillingMode.InAdvance, - Cadence = PriceMinimumCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() - { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], - }, - Currency = "currency", - Discount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", - }, - MinimumAmount = "minimum_amount", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "name", - PlanPhaseOrder = 0, - PriceType = PriceMinimumPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - }, - }; - - string expectedID = "id"; - BillableMetricTiny expectedBillableMetric = new("id"); - BillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = DurationUnit.Day, - }; - ApiEnum expectedBillingMode = - PriceMinimumBillingMode.InAdvance; - ApiEnum expectedCadence = PriceMinimumCadence.OneTime; - List expectedCompositePriceFilters = - [ - new() - { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ]; - double expectedConversionRate = 0; - PriceMinimumConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Allocation expectedCreditAllocation = new() - { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], - }; - string expectedCurrency = "currency"; - SharedDiscount expectedDiscount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = DurationUnit.Day, - }; - ItemSlim expectedItem = new() { ID = "id", Name = "name" }; - Maximum expectedMaximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }; - string expectedMaximumAmount = "maximum_amount"; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - Minimum expectedMinimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", - }; - string expectedMinimumAmount = "minimum_amount"; - MinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); - string expectedName = "name"; - long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = PriceMinimumPriceType.UsagePrice; - string expectedReplacesPriceID = "replaces_price_id"; - DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - }; - - Assert.Equal(expectedID, model.ID); - Assert.Equal(expectedBillableMetric, model.BillableMetric); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedBillingMode, model.BillingMode); - Assert.Equal(expectedCadence, model.Cadence); - Assert.NotNull(model.CompositePriceFilters); - Assert.Equal(expectedCompositePriceFilters.Count, model.CompositePriceFilters.Count); - for (int i = 0; i < expectedCompositePriceFilters.Count; i++) - { - Assert.Equal(expectedCompositePriceFilters[i], model.CompositePriceFilters[i]); - } - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedCreatedAt, model.CreatedAt); - Assert.Equal(expectedCreditAllocation, model.CreditAllocation); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedDiscount, model.Discount); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); - Assert.Equal(expectedItem, model.Item); - Assert.Equal(expectedMaximum, model.Maximum); - Assert.Equal(expectedMaximumAmount, model.MaximumAmount); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedMinimum, model.Minimum); - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedMinimumConfig, model.MinimumConfig); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); - Assert.Equal(expectedPriceType, model.PriceType); - Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new PriceMinimum - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PriceMinimumBillingMode.InAdvance, - Cadence = PriceMinimumCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() - { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], - }, - Currency = "currency", - Discount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", - }, - MinimumAmount = "minimum_amount", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "name", - PlanPhaseOrder = 0, - PriceType = PriceMinimumPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - }, - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new PriceMinimum - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PriceMinimumBillingMode.InAdvance, - Cadence = PriceMinimumCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() - { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], - }, - Currency = "currency", - Discount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", - }, - MinimumAmount = "minimum_amount", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "name", - PlanPhaseOrder = 0, - PriceType = PriceMinimumPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - }, - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedID = "id"; - BillableMetricTiny expectedBillableMetric = new("id"); - BillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = DurationUnit.Day, - }; - ApiEnum expectedBillingMode = - PriceMinimumBillingMode.InAdvance; - ApiEnum expectedCadence = PriceMinimumCadence.OneTime; - List expectedCompositePriceFilters = - [ - new() - { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ]; - double expectedConversionRate = 0; - PriceMinimumConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Allocation expectedCreditAllocation = new() - { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], - }; - string expectedCurrency = "currency"; - SharedDiscount expectedDiscount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = DurationUnit.Day, - }; - ItemSlim expectedItem = new() { ID = "id", Name = "name" }; - Maximum expectedMaximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }; - string expectedMaximumAmount = "maximum_amount"; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - Minimum expectedMinimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", - }; - string expectedMinimumAmount = "minimum_amount"; - MinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); - string expectedName = "name"; - long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = PriceMinimumPriceType.UsagePrice; - string expectedReplacesPriceID = "replaces_price_id"; - DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - }; - - Assert.Equal(expectedID, deserialized.ID); - Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedBillingMode, deserialized.BillingMode); - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.NotNull(deserialized.CompositePriceFilters); - Assert.Equal(expectedCompositePriceFilters.Count, deserialized.CompositePriceFilters.Count); - for (int i = 0; i < expectedCompositePriceFilters.Count; i++) - { - Assert.Equal(expectedCompositePriceFilters[i], deserialized.CompositePriceFilters[i]); - } - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); - Assert.Equal(expectedCreditAllocation, deserialized.CreditAllocation); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal(expectedDiscount, deserialized.Discount); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.Equal(expectedItem, deserialized.Item); - Assert.Equal(expectedMaximum, deserialized.Maximum); - Assert.Equal(expectedMaximumAmount, deserialized.MaximumAmount); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedMinimum, deserialized.Minimum); - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedMinimumConfig, deserialized.MinimumConfig); - Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - Assert.Equal(expectedPriceType, deserialized.PriceType); - Assert.Equal(expectedReplacesPriceID, deserialized.ReplacesPriceID); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); - } - - [Fact] - public void Validation_Works() - { - var model = new PriceMinimum - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PriceMinimumBillingMode.InAdvance, - Cadence = PriceMinimumCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() - { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], - }, - Currency = "currency", - Discount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", - }, - MinimumAmount = "minimum_amount", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "name", - PlanPhaseOrder = 0, - PriceType = PriceMinimumPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - }, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new PriceMinimum - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PriceMinimumBillingMode.InAdvance, - Cadence = PriceMinimumCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() - { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], - }, - Currency = "currency", - Discount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", - }, - MinimumAmount = "minimum_amount", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "name", - PlanPhaseOrder = 0, - PriceType = PriceMinimumPriceType.UsagePrice, + PriceType = CumulativeGroupedAllocationPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", }; @@ -62071,19 +60060,19 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new PriceMinimum + var model = new CumulativeGroupedAllocation { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PriceMinimumBillingMode.InAdvance, - Cadence = PriceMinimumCadence.OneTime, + BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, + Cadence = CumulativeGroupedAllocationCadence.OneTime, CompositePriceFilters = [ new() { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -62113,6 +60102,13 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ], }, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, Currency = "currency", Discount = new PercentageDiscount() { @@ -62165,10 +60161,9 @@ public void OptionalNullablePropertiesUnsetValidation_Works() MinimumAmount = "minimum_amount", }, MinimumAmount = "minimum_amount", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "name", PlanPhaseOrder = 0, - PriceType = PriceMinimumPriceType.UsagePrice, + PriceType = CumulativeGroupedAllocationPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", }; @@ -62178,19 +60173,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new PriceMinimum + var model = new CumulativeGroupedAllocation { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PriceMinimumBillingMode.InAdvance, - Cadence = PriceMinimumCadence.OneTime, + BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, + Cadence = CumulativeGroupedAllocationCadence.OneTime, CompositePriceFilters = [ new() { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -62220,6 +60215,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ], }, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, Currency = "currency", Discount = new PercentageDiscount() { @@ -62272,10 +60274,9 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() MinimumAmount = "minimum_amount", }, MinimumAmount = "minimum_amount", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "name", PlanPhaseOrder = 0, - PriceType = PriceMinimumPriceType.UsagePrice, + PriceType = CumulativeGroupedAllocationPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, @@ -62288,19 +60289,19 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new PriceMinimum + var model = new CumulativeGroupedAllocation { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PriceMinimumBillingMode.InAdvance, - Cadence = PriceMinimumCadence.OneTime, + BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, + Cadence = CumulativeGroupedAllocationCadence.OneTime, CompositePriceFilters = [ new() { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -62330,6 +60331,13 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ], }, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, Currency = "currency", Discount = new PercentageDiscount() { @@ -62382,10 +60390,9 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() MinimumAmount = "minimum_amount", }, MinimumAmount = "minimum_amount", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "name", PlanPhaseOrder = 0, - PriceType = PriceMinimumPriceType.UsagePrice, + PriceType = CumulativeGroupedAllocationPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, @@ -62395,43 +60402,41 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class PriceMinimumBillingModeTest : TestBase +public class CumulativeGroupedAllocationBillingModeTest : TestBase { [Theory] - [InlineData(PriceMinimumBillingMode.InAdvance)] - [InlineData(PriceMinimumBillingMode.InArrear)] - public void Validation_Works(PriceMinimumBillingMode rawValue) + [InlineData(CumulativeGroupedAllocationBillingMode.InAdvance)] + [InlineData(CumulativeGroupedAllocationBillingMode.InArrear)] + public void Validation_Works(CumulativeGroupedAllocationBillingMode rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); Assert.Throws(() => value.Validate()); } [Theory] - [InlineData(PriceMinimumBillingMode.InAdvance)] - [InlineData(PriceMinimumBillingMode.InArrear)] - public void SerializationRoundtrip_Works(PriceMinimumBillingMode rawValue) + [InlineData(CumulativeGroupedAllocationBillingMode.InAdvance)] + [InlineData(CumulativeGroupedAllocationBillingMode.InArrear)] + public void SerializationRoundtrip_Works(CumulativeGroupedAllocationBillingMode rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } @@ -62439,40 +60444,38 @@ public void SerializationRoundtrip_Works(PriceMinimumBillingMode rawValue) [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class PriceMinimumCadenceTest : TestBase +public class CumulativeGroupedAllocationCadenceTest : TestBase { [Theory] - [InlineData(PriceMinimumCadence.OneTime)] - [InlineData(PriceMinimumCadence.Monthly)] - [InlineData(PriceMinimumCadence.Quarterly)] - [InlineData(PriceMinimumCadence.SemiAnnual)] - [InlineData(PriceMinimumCadence.Annual)] - [InlineData(PriceMinimumCadence.Custom)] - public void Validation_Works(PriceMinimumCadence rawValue) + [InlineData(CumulativeGroupedAllocationCadence.OneTime)] + [InlineData(CumulativeGroupedAllocationCadence.Monthly)] + [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(CumulativeGroupedAllocationCadence.Annual)] + [InlineData(CumulativeGroupedAllocationCadence.Custom)] + public void Validation_Works(CumulativeGroupedAllocationCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -62482,22 +60485,21 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(PriceMinimumCadence.OneTime)] - [InlineData(PriceMinimumCadence.Monthly)] - [InlineData(PriceMinimumCadence.Quarterly)] - [InlineData(PriceMinimumCadence.SemiAnnual)] - [InlineData(PriceMinimumCadence.Annual)] - [InlineData(PriceMinimumCadence.Custom)] - public void SerializationRoundtrip_Works(PriceMinimumCadence rawValue) + [InlineData(CumulativeGroupedAllocationCadence.OneTime)] + [InlineData(CumulativeGroupedAllocationCadence.Monthly)] + [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(CumulativeGroupedAllocationCadence.Annual)] + [InlineData(CumulativeGroupedAllocationCadence.Custom)] + public void SerializationRoundtrip_Works(CumulativeGroupedAllocationCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } @@ -62505,36 +60507,35 @@ public void SerializationRoundtrip_Works(PriceMinimumCadence rawValue) [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class PriceMinimumCompositePriceFilterTest : TestBase +public class CumulativeGroupedAllocationCompositePriceFilterTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new PriceMinimumCompositePriceFilter + var model = new CumulativeGroupedAllocationCompositePriceFilter { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }; - ApiEnum expectedField = - PriceMinimumCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - PriceMinimumCompositePriceFilterOperator.Includes; + ApiEnum expectedField = + CumulativeGroupedAllocationCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + CumulativeGroupedAllocationCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, model.Field); @@ -62549,18 +60550,19 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new PriceMinimumCompositePriceFilter + var model = new CumulativeGroupedAllocationCompositePriceFilter { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -62568,24 +60570,25 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new PriceMinimumCompositePriceFilter + var model = new CumulativeGroupedAllocationCompositePriceFilter { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); - ApiEnum expectedField = - PriceMinimumCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - PriceMinimumCompositePriceFilterOperator.Includes; + ApiEnum expectedField = + CumulativeGroupedAllocationCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + CumulativeGroupedAllocationCompositePriceFilterOperator.Includes; List expectedValues = ["string"]; Assert.Equal(expectedField, deserialized.Field); @@ -62600,10 +60603,10 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new PriceMinimumCompositePriceFilter + var model = new CumulativeGroupedAllocationCompositePriceFilter { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, Values = ["string"], }; @@ -62611,18 +60614,18 @@ public void Validation_Works() } } -public class PriceMinimumCompositePriceFilterFieldTest : TestBase +public class CumulativeGroupedAllocationCompositePriceFilterFieldTest : TestBase { [Theory] - [InlineData(PriceMinimumCompositePriceFilterField.PriceID)] - [InlineData(PriceMinimumCompositePriceFilterField.ItemID)] - [InlineData(PriceMinimumCompositePriceFilterField.PriceType)] - [InlineData(PriceMinimumCompositePriceFilterField.Currency)] - [InlineData(PriceMinimumCompositePriceFilterField.PricingUnitID)] - public void Validation_Works(PriceMinimumCompositePriceFilterField rawValue) + [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.PriceID)] + [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.ItemID)] + [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.PriceType)] + [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.Currency)] + [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.PricingUnitID)] + public void Validation_Works(CumulativeGroupedAllocationCompositePriceFilterField rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -62630,7 +60633,7 @@ public void Validation_Works(PriceMinimumCompositePriceFilterField rawValue) public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -62638,19 +60641,21 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(PriceMinimumCompositePriceFilterField.PriceID)] - [InlineData(PriceMinimumCompositePriceFilterField.ItemID)] - [InlineData(PriceMinimumCompositePriceFilterField.PriceType)] - [InlineData(PriceMinimumCompositePriceFilterField.Currency)] - [InlineData(PriceMinimumCompositePriceFilterField.PricingUnitID)] - public void SerializationRoundtrip_Works(PriceMinimumCompositePriceFilterField rawValue) + [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.PriceID)] + [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.ItemID)] + [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.PriceType)] + [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.Currency)] + [InlineData(CumulativeGroupedAllocationCompositePriceFilterField.PricingUnitID)] + public void SerializationRoundtrip_Works( + CumulativeGroupedAllocationCompositePriceFilterField rawValue + ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -62660,26 +60665,26 @@ public void SerializationRoundtrip_Works(PriceMinimumCompositePriceFilterField r public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class PriceMinimumCompositePriceFilterOperatorTest : TestBase +public class CumulativeGroupedAllocationCompositePriceFilterOperatorTest : TestBase { [Theory] - [InlineData(PriceMinimumCompositePriceFilterOperator.Includes)] - [InlineData(PriceMinimumCompositePriceFilterOperator.Excludes)] - public void Validation_Works(PriceMinimumCompositePriceFilterOperator rawValue) + [InlineData(CumulativeGroupedAllocationCompositePriceFilterOperator.Includes)] + [InlineData(CumulativeGroupedAllocationCompositePriceFilterOperator.Excludes)] + public void Validation_Works(CumulativeGroupedAllocationCompositePriceFilterOperator rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -62687,7 +60692,7 @@ public void Validation_Works(PriceMinimumCompositePriceFilterOperator rawValue) public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -62695,16 +60700,18 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(PriceMinimumCompositePriceFilterOperator.Includes)] - [InlineData(PriceMinimumCompositePriceFilterOperator.Excludes)] - public void SerializationRoundtrip_Works(PriceMinimumCompositePriceFilterOperator rawValue) + [InlineData(CumulativeGroupedAllocationCompositePriceFilterOperator.Includes)] + [InlineData(CumulativeGroupedAllocationCompositePriceFilterOperator.Excludes)] + public void SerializationRoundtrip_Works( + CumulativeGroupedAllocationCompositePriceFilterOperator rawValue + ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -62714,23 +60721,23 @@ public void SerializationRoundtrip_Works(PriceMinimumCompositePriceFilterOperato public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class PriceMinimumConversionRateConfigTest : TestBase +public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - PriceMinimumConversionRateConfig value = new SharedUnitConversionRateConfig() + CumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -62741,36 +60748,38 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - PriceMinimumConversionRateConfig value = new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + CumulativeGroupedAllocationConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; value.Validate(); } [Fact] public void UnitSerializationRoundtripWorks() { - PriceMinimumConversionRateConfig value = new SharedUnitConversionRateConfig() + CumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -62778,51 +60787,69 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - PriceMinimumConversionRateConfig value = new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + CumulativeGroupedAllocationConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class MinimumConfigTest : TestBase +public class CumulativeGroupedAllocationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new CumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, model.GroupAllocation); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new CumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -62833,116 +60860,84 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new CumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() - { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() - { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() - { - var model = new MinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() - { - var model = new MinimumConfig + var model = new CumulativeGroupedAllocationConfig { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; model.Validate(); } } -public class PriceMinimumPriceTypeTest : TestBase +public class CumulativeGroupedAllocationPriceTypeTest : TestBase { [Theory] - [InlineData(PriceMinimumPriceType.UsagePrice)] - [InlineData(PriceMinimumPriceType.FixedPrice)] - [InlineData(PriceMinimumPriceType.CompositePrice)] - public void Validation_Works(PriceMinimumPriceType rawValue) + [InlineData(CumulativeGroupedAllocationPriceType.UsagePrice)] + [InlineData(CumulativeGroupedAllocationPriceType.FixedPrice)] + [InlineData(CumulativeGroupedAllocationPriceType.CompositePrice)] + public void Validation_Works(CumulativeGroupedAllocationPriceType rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); Assert.Throws(() => value.Validate()); } [Theory] - [InlineData(PriceMinimumPriceType.UsagePrice)] - [InlineData(PriceMinimumPriceType.FixedPrice)] - [InlineData(PriceMinimumPriceType.CompositePrice)] - public void SerializationRoundtrip_Works(PriceMinimumPriceType rawValue) + [InlineData(CumulativeGroupedAllocationPriceType.UsagePrice)] + [InlineData(CumulativeGroupedAllocationPriceType.FixedPrice)] + [InlineData(CumulativeGroupedAllocationPriceType.CompositePrice)] + public void SerializationRoundtrip_Works(CumulativeGroupedAllocationPriceType rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } @@ -62950,15 +60945,13 @@ public void SerializationRoundtrip_Works(PriceMinimumPriceType rawValue) [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } diff --git a/src/Orb.Tests/Models/Prices/ExternalPriceID/ExternalPriceIDFetchParamsTest.cs b/src/Orb.Tests/Models/Prices/ExternalPriceID/ExternalPriceIDFetchParamsTest.cs index 738921ad..62357667 100644 --- a/src/Orb.Tests/Models/Prices/ExternalPriceID/ExternalPriceIDFetchParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/ExternalPriceID/ExternalPriceIDFetchParamsTest.cs @@ -27,4 +27,14 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ExternalPriceIDFetchParams { ExternalPriceID = "external_price_id" }; + + ExternalPriceIDFetchParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Prices/ExternalPriceID/ExternalPriceIDUpdateParamsTest.cs b/src/Orb.Tests/Models/Prices/ExternalPriceID/ExternalPriceIDUpdateParamsTest.cs index 29268eac..f3fff77c 100644 --- a/src/Orb.Tests/Models/Prices/ExternalPriceID/ExternalPriceIDUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/ExternalPriceID/ExternalPriceIDUpdateParamsTest.cs @@ -64,4 +64,18 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ExternalPriceIDUpdateParams + { + ExternalPriceID = "external_price_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + ExternalPriceIDUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Prices/PriceCreateParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceCreateParamsTest.cs index 494a3583..a5714c81 100644 --- a/src/Orb.Tests/Models/Prices/PriceCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceCreateParamsTest.cs @@ -145,6 +145,56 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/prices"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new PriceCreateParams + { + Body = new Models::NewFloatingUnitPrice() + { + Cadence = Models::NewFloatingUnitPriceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + ModelType = Models::NewFloatingUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + }, + }; + + PriceCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class BodyTest : TestBase @@ -1574,48 +1624,6 @@ public void CumulativeGroupedAllocationValidationWorks() value.Validate(); } - [Fact] - public void MinimumValidationWorks() - { - Body value = new Minimum() - { - Cadence = MinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - value.Validate(); - } - [Fact] public void NewFloatingMinimumCompositePriceValidationWorks() { @@ -3257,51 +3265,6 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Assert.Equal(value, deserialized); } - [Fact] - public void MinimumSerializationRoundtripWorks() - { - Body value = new Minimum() - { - Cadence = MinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - [Fact] public void NewFloatingMinimumCompositePriceSerializationRoundtripWorks() { @@ -5842,691 +5805,6 @@ public void TieredSerializationRoundtripWorks() } } -public class MinimumTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new Minimum - { - Cadence = MinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - - ApiEnum expectedCadence = MinimumCadence.Annual; - string expectedCurrency = "currency"; - string expectedItemID = "item_id"; - MinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - MinimumConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - - Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedItemID, model.ItemID); - Assert.Equal(expectedMinimumConfig, model.MinimumConfig); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); - Assert.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, model.Metadata[item.Key]); - } - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new Minimum - { - Cadence = MinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new Minimum - { - Cadence = MinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - ApiEnum expectedCadence = MinimumCadence.Annual; - string expectedCurrency = "currency"; - string expectedItemID = "item_id"; - MinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - MinimumConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.Equal(expectedMinimumConfig, deserialized.MinimumConfig); - Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - } - - [Fact] - public void Validation_Works() - { - var model = new Minimum - { - Cadence = MinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new Minimum - { - Cadence = MinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - }; - - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new Minimum - { - Cadence = MinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new Minimum - { - Cadence = MinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - }; - - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.True(model.RawData.ContainsKey("metadata")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new Minimum - { - Cadence = MinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - }; - - model.Validate(); - } -} - -public class MinimumCadenceTest : TestBase -{ - [Theory] - [InlineData(MinimumCadence.Annual)] - [InlineData(MinimumCadence.SemiAnnual)] - [InlineData(MinimumCadence.Monthly)] - [InlineData(MinimumCadence.Quarterly)] - [InlineData(MinimumCadence.OneTime)] - [InlineData(MinimumCadence.Custom)] - public void Validation_Works(MinimumCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(MinimumCadence.Annual)] - [InlineData(MinimumCadence.SemiAnnual)] - [InlineData(MinimumCadence.Monthly)] - [InlineData(MinimumCadence.Quarterly)] - [InlineData(MinimumCadence.OneTime)] - [InlineData(MinimumCadence.Custom)] - public void SerializationRoundtrip_Works(MinimumCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - -public class MinimumConfigTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; - - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; - - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; - - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); - } - - [Fact] - public void Validation_Works() - { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() - { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() - { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() - { - var model = new MinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() - { - var model = new MinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; - - model.Validate(); - } -} - -public class MinimumConversionRateConfigTest : TestBase -{ - [Fact] - public void UnitValidationWorks() - { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() - { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); - } - - [Fact] - public void UnitSerializationRoundtripWorks() - { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void TieredSerializationRoundtripWorks() - { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - public class PercentTest : TestBase { [Fact] diff --git a/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleParamsTest.cs index e37fc01b..a5fa9e78 100644 --- a/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceEvaluateMultipleParamsTest.cs @@ -309,6 +309,70 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/prices/evaluate"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new PriceEvaluateMultipleParams + { + TimeframeEnd = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomerID = "customer_id", + ExternalCustomerID = "external_customer_id", + PriceEvaluations = + [ + new() + { + ExternalPriceID = "external_price_id", + Filter = "my_numeric_property > 100 AND my_other_property = 'bar'", + GroupingKeys = ["case when my_event_type = 'foo' then true else false end"], + Price = new Models::NewFloatingUnitPrice() + { + Cadence = Models::NewFloatingUnitPriceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + ModelType = Models::NewFloatingUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = + Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + }, + PriceID = "price_id", + }, + ], + }; + + PriceEvaluateMultipleParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class PriceEvaluationTest : TestBase @@ -2350,48 +2414,6 @@ public void CumulativeGroupedAllocationValidationWorks() value.Validate(); } - [Fact] - public void MinimumValidationWorks() - { - Price value = new PriceMinimum() - { - Cadence = PriceMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - value.Validate(); - } - [Fact] public void NewFloatingMinimumCompositeValidationWorks() { @@ -4033,51 +4055,6 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Assert.Equal(value, deserialized); } - [Fact] - public void MinimumSerializationRoundtripWorks() - { - Price value = new PriceMinimum() - { - Cadence = PriceMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - [Fact] public void NewFloatingMinimumCompositeSerializationRoundtripWorks() { @@ -6688,710 +6665,6 @@ public void TieredSerializationRoundtripWorks() } } -public class PriceMinimumTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new PriceMinimum - { - Cadence = PriceMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - - ApiEnum expectedCadence = PriceMinimumCadence.Annual; - string expectedCurrency = "currency"; - string expectedItemID = "item_id"; - PriceMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - PriceMinimumConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - - Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedItemID, model.ItemID); - Assert.Equal(expectedMinimumConfig, model.MinimumConfig); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); - Assert.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, model.Metadata[item.Key]); - } - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new PriceMinimum - { - Cadence = PriceMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new PriceMinimum - { - Cadence = PriceMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - ApiEnum expectedCadence = PriceMinimumCadence.Annual; - string expectedCurrency = "currency"; - string expectedItemID = "item_id"; - PriceMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - PriceMinimumConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.Equal(expectedMinimumConfig, deserialized.MinimumConfig); - Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - } - - [Fact] - public void Validation_Works() - { - var model = new PriceMinimum - { - Cadence = PriceMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new PriceMinimum - { - Cadence = PriceMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - }; - - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new PriceMinimum - { - Cadence = PriceMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new PriceMinimum - { - Cadence = PriceMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - }; - - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.True(model.RawData.ContainsKey("metadata")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new PriceMinimum - { - Cadence = PriceMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - }; - - model.Validate(); - } -} - -public class PriceMinimumCadenceTest : TestBase -{ - [Theory] - [InlineData(PriceMinimumCadence.Annual)] - [InlineData(PriceMinimumCadence.SemiAnnual)] - [InlineData(PriceMinimumCadence.Monthly)] - [InlineData(PriceMinimumCadence.Quarterly)] - [InlineData(PriceMinimumCadence.OneTime)] - [InlineData(PriceMinimumCadence.Custom)] - public void Validation_Works(PriceMinimumCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(PriceMinimumCadence.Annual)] - [InlineData(PriceMinimumCadence.SemiAnnual)] - [InlineData(PriceMinimumCadence.Monthly)] - [InlineData(PriceMinimumCadence.Quarterly)] - [InlineData(PriceMinimumCadence.OneTime)] - [InlineData(PriceMinimumCadence.Custom)] - public void SerializationRoundtrip_Works(PriceMinimumCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - -public class PriceMinimumMinimumConfigTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new PriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; - - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new PriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new PriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; - - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); - } - - [Fact] - public void Validation_Works() - { - var model = new PriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() - { - var model = new PriceMinimumMinimumConfig { MinimumAmount = "minimum_amount" }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() - { - var model = new PriceMinimumMinimumConfig { MinimumAmount = "minimum_amount" }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() - { - var model = new PriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() - { - var model = new PriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; - - model.Validate(); - } -} - -public class PriceMinimumConversionRateConfigTest : TestBase -{ - [Fact] - public void UnitValidationWorks() - { - PriceMinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() - { - PriceMinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); - } - - [Fact] - public void UnitSerializationRoundtripWorks() - { - PriceMinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void TieredSerializationRoundtripWorks() - { - PriceMinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - public class PricePercentTest : TestBase { [Fact] diff --git a/src/Orb.Tests/Models/Prices/PriceEvaluateParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceEvaluateParamsTest.cs index 43543de0..c3660fc0 100644 --- a/src/Orb.Tests/Models/Prices/PriceEvaluateParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceEvaluateParamsTest.cs @@ -138,4 +138,23 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/prices/price_id/evaluate"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new PriceEvaluateParams + { + PriceID = "price_id", + TimeframeEnd = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomerID = "customer_id", + ExternalCustomerID = "external_customer_id", + Filter = "my_numeric_property > 100 AND my_other_property = 'bar'", + GroupingKeys = ["case when my_event_type = 'foo' then true else false end"], + }; + + PriceEvaluateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsParamsTest.cs index 1f1efee6..26188913 100644 --- a/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceEvaluatePreviewEventsParamsTest.cs @@ -375,6 +375,84 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/prices/evaluate_preview_events"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new PriceEvaluatePreviewEventsParams + { + TimeframeEnd = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CustomerID = "customer_id", + Events = + [ + new() + { + EventName = "event_name", + Properties = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Timestamp = DateTimeOffset.Parse("2020-12-09T16:09:53Z"), + CustomerID = "customer_id", + ExternalCustomerID = "external_customer_id", + }, + ], + ExternalCustomerID = "external_customer_id", + PriceEvaluations = + [ + new() + { + ExternalPriceID = "external_price_id", + Filter = "my_numeric_property > 100 AND my_other_property = 'bar'", + GroupingKeys = ["case when my_event_type = 'foo' then true else false end"], + Price = new NewFloatingUnitPrice() + { + Cadence = NewFloatingUnitPriceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + ModelType = NewFloatingUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = + SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + }, + PriceID = "price_id", + }, + ], + }; + + PriceEvaluatePreviewEventsParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class EventTest : TestBase @@ -2637,49 +2715,6 @@ public void CumulativeGroupedAllocationValidationWorks() value.Validate(); } - [Fact] - public void MinimumValidationWorks() - { - PriceEvaluatePreviewEventsParamsPriceEvaluationPrice value = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum() - { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - value.Validate(); - } - [Fact] public void NewFloatingMinimumCompositeValidationWorks() { @@ -4470,56 +4505,6 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Assert.Equal(value, deserialized); } - [Fact] - public void MinimumSerializationRoundtripWorks() - { - PriceEvaluatePreviewEventsParamsPriceEvaluationPrice value = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum() - { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - [Fact] public void NewFloatingMinimumCompositeSerializationRoundtripWorks() { @@ -7375,731 +7360,6 @@ public void TieredSerializationRoundtripWorks() } } -public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum - { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - - ApiEnum< - string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence - > expectedCadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual; - string expectedCurrency = "currency"; - string expectedItemID = "item_id"; - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig expectedMinimumConfig = - new() { MinimumAmount = "minimum_amount", Prorated = true }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - - Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedItemID, model.ItemID); - Assert.Equal(expectedMinimumConfig, model.MinimumConfig); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); - Assert.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, model.Metadata[item.Key]); - } - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum - { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum - { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - ApiEnum< - string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence - > expectedCadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual; - string expectedCurrency = "currency"; - string expectedItemID = "item_id"; - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig expectedMinimumConfig = - new() { MinimumAmount = "minimum_amount", Prorated = true }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.Equal(expectedMinimumConfig, deserialized.MinimumConfig); - Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - } - - [Fact] - public void Validation_Works() - { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum - { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum - { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - }; - - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum - { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum - { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - }; - - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.True(model.RawData.ContainsKey("metadata")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum - { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - }; - - model.Validate(); - } -} - -public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadenceTest : TestBase -{ - [Theory] - [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual)] - [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.SemiAnnual)] - [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Monthly)] - [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Quarterly)] - [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.OneTime)] - [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Custom)] - public void Validation_Works( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence rawValue - ) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = - rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual)] - [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.SemiAnnual)] - [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Monthly)] - [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Quarterly)] - [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.OneTime)] - [InlineData(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Custom)] - public void SerializationRoundtrip_Works( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence rawValue - ) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = - rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } -} - -public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfigTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; - - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; - - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); - } - - [Fact] - public void Validation_Works() - { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() - { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() - { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() - { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() - { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; - - model.Validate(); - } -} - -public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfigTest - : TestBase -{ - [Fact] - public void UnitValidationWorks() - { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig value = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() - { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig value = - new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); - } - - [Fact] - public void UnitSerializationRoundtripWorks() - { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig value = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void TieredSerializationRoundtripWorks() - { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig value = - new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - public class PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentTest : TestBase { [Fact] diff --git a/src/Orb.Tests/Models/Prices/PriceFetchParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceFetchParamsTest.cs index 4c0d5554..49c3495a 100644 --- a/src/Orb.Tests/Models/Prices/PriceFetchParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceFetchParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/prices/price_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new PriceFetchParams { PriceID = "price_id" }; + + PriceFetchParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Prices/PriceListParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceListParamsTest.cs index 4d2939a6..8cf4df1c 100644 --- a/src/Orb.Tests/Models/Prices/PriceListParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceListParamsTest.cs @@ -73,4 +73,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/prices?cursor=cursor&limit=1"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new PriceListParams { Cursor = "cursor", Limit = 1 }; + + PriceListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Prices/PriceUpdateParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceUpdateParamsTest.cs index 16fb1492..fb190cf1 100644 --- a/src/Orb.Tests/Models/Prices/PriceUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Prices/PriceUpdateParamsTest.cs @@ -61,4 +61,18 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/prices/price_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new PriceUpdateParams + { + PriceID = "price_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + PriceUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeApplyParamsTest.cs b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeApplyParamsTest.cs index 46487b5c..10d76399 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeApplyParamsTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeApplyParamsTest.cs @@ -102,4 +102,23 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionChangeApplyParams + { + SubscriptionChangeID = "subscription_change_id", + Description = "description", + MarkAsPaid = true, + PaymentExternalID = "payment_external_id", + PaymentNotes = "payment_notes", + PaymentReceivedDate = "2019-12-27", + PreviouslyCollectedAmount = "previously_collected_amount", + }; + + SubscriptionChangeApplyParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeCancelParamsTest.cs b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeCancelParamsTest.cs index 386c09a5..dd6cc7ea 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeCancelParamsTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeCancelParamsTest.cs @@ -35,4 +35,17 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionChangeCancelParams + { + SubscriptionChangeID = "subscription_change_id", + }; + + SubscriptionChangeCancelParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeListParamsTest.cs b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeListParamsTest.cs index adb44630..3bca69a2 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeListParamsTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeListParamsTest.cs @@ -125,6 +125,23 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionChangeListParams + { + Cursor = "cursor", + CustomerID = "customer_id", + ExternalCustomerID = "external_customer_id", + Limit = 1, + Status = Status.Pending, + }; + + SubscriptionChangeListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class StatusTest : TestBase diff --git a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeRetrieveParamsTest.cs b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeRetrieveParamsTest.cs index ef32817f..0148a7b0 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeRetrieveParamsTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeRetrieveParamsTest.cs @@ -33,4 +33,17 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionChangeRetrieveParams + { + SubscriptionChangeID = "subscription_change_id", + }; + + SubscriptionChangeRetrieveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionCancelParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionCancelParamsTest.cs index 3bbdac17..038e5f8f 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionCancelParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionCancelParamsTest.cs @@ -79,6 +79,22 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionCancelParams + { + SubscriptionID = "subscription_id", + CancelOption = CancelOption.EndOfSubscriptionTerm, + AllowInvoiceCreditOrVoid = true, + CancellationDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + SubscriptionCancelParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class CancelOptionTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs index 2e4a1b44..d7fb74b5 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionCreateParamsTest.cs @@ -1375,2987 +1375,780 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/subscriptions"), url); } -} -public class AddAdjustmentTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void CopyConstructor_Works() { - var model = new Subscriptions::AddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PlanPhaseOrder = 0, - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - Subscriptions::Adjustment expectedAdjustment = new NewPercentageDiscount() + var parameters = new Subscriptions::SubscriptionCreateParams { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + AddAdjustments = [ new() { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhaseOrder = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }, ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }; - DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - long expectedPlanPhaseOrder = 0; - DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - - Assert.Equal(expectedAdjustment, model.Adjustment); - Assert.Equal(expectedEndDate, model.EndDate); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); - Assert.Equal(expectedStartDate, model.StartDate); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new Subscriptions::AddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() + AddPrices = + [ + new() + { + AllocationPrice = new() { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PlanPhaseOrder = 0, - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new Subscriptions::AddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() + Discounts = + [ + new() + { + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, + }, + ], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalPriceID = "external_price_id", + MaximumAmount = "1.23", + MinimumAmount = "1.23", + PlanPhaseOrder = 0, + Price = new Subscriptions::NewSubscriptionUnitPrice() { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = + SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PlanPhaseOrder = 0, - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - Subscriptions::Adjustment expectedAdjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + PriceID = "h74gfhdjvn7ujokd", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }, ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }; - DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - long expectedPlanPhaseOrder = 0; - DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - - Assert.Equal(expectedAdjustment, deserialized.Adjustment); - Assert.Equal(expectedEndDate, deserialized.EndDate); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - Assert.Equal(expectedStartDate, deserialized.StartDate); - } - - [Fact] - public void Validation_Works() - { - var model = new Subscriptions::AddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PlanPhaseOrder = 0, - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new Subscriptions::AddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - }; - - Assert.Null(model.EndDate); - Assert.False(model.RawData.ContainsKey("end_date")); - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); - Assert.Null(model.StartDate); - Assert.False(model.RawData.ContainsKey("start_date")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::AddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new Subscriptions::AddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - - EndDate = null, - PlanPhaseOrder = null, - StartDate = null, - }; - - Assert.Null(model.EndDate); - Assert.True(model.RawData.ContainsKey("end_date")); - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); - Assert.Null(model.StartDate); - Assert.True(model.RawData.ContainsKey("start_date")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new Subscriptions::AddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - - EndDate = null, - PlanPhaseOrder = null, - StartDate = null, - }; - - model.Validate(); - } -} - -public class AdjustmentTest : TestBase -{ - [Fact] - public void NewPercentageDiscountValidationWorks() - { - Subscriptions::Adjustment value = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }; - value.Validate(); - } - - [Fact] - public void NewUsageDiscountValidationWorks() - { - Subscriptions::Adjustment value = new NewUsageDiscount() - { - AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewUsageDiscountFilterField.PriceID, - Operator = NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewUsageDiscountPriceType.Usage, - }; - value.Validate(); - } - - [Fact] - public void NewAmountDiscountValidationWorks() - { - Subscriptions::Adjustment value = new NewAmountDiscount() - { - AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewAmountDiscountFilterField.PriceID, - Operator = NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = PriceType.Usage, - }; - value.Validate(); - } - - [Fact] - public void NewMinimumValidationWorks() - { - Subscriptions::Adjustment value = new NewMinimum() - { - AdjustmentType = NewMinimumAdjustmentType.Minimum, - ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMinimumFilterField.PriceID, - Operator = NewMinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMinimumPriceType.Usage, - }; - value.Validate(); - } - - [Fact] - public void NewMaximumValidationWorks() - { - Subscriptions::Adjustment value = new NewMaximum() - { - AdjustmentType = NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMaximumFilterField.PriceID, - Operator = NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMaximumPriceType.Usage, - }; - value.Validate(); - } - - [Fact] - public void NewPercentageDiscountSerializationRoundtripWorks() - { - Subscriptions::Adjustment value = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewUsageDiscountSerializationRoundtripWorks() - { - Subscriptions::Adjustment value = new NewUsageDiscount() - { - AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewUsageDiscountFilterField.PriceID, - Operator = NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewUsageDiscountPriceType.Usage, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewAmountDiscountSerializationRoundtripWorks() - { - Subscriptions::Adjustment value = new NewAmountDiscount() - { - AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewAmountDiscountFilterField.PriceID, - Operator = NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = PriceType.Usage, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewMinimumSerializationRoundtripWorks() - { - Subscriptions::Adjustment value = new NewMinimum() - { - AdjustmentType = NewMinimumAdjustmentType.Minimum, - ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMinimumFilterField.PriceID, - Operator = NewMinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMinimumPriceType.Usage, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewMaximumSerializationRoundtripWorks() - { - Subscriptions::Adjustment value = new NewMaximum() - { - AdjustmentType = NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMaximumFilterField.PriceID, - Operator = NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMaximumPriceType.Usage, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - -public class AddPriceTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new Subscriptions::AddPrice - { - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ], - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - ExternalPriceID = "external_price_id", - MaximumAmount = "1.23", - MinimumAmount = "1.23", - PlanPhaseOrder = 0, - Price = new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }, - PriceID = "h74gfhdjvn7ujokd", - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - NewAllocationPrice expectedAllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }; - List expectedDiscounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ]; - DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - string expectedExternalPriceID = "external_price_id"; - string expectedMaximumAmount = "1.23"; - string expectedMinimumAmount = "1.23"; - long expectedPlanPhaseOrder = 0; - Subscriptions::Price expectedPrice = new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string expectedPriceID = "h74gfhdjvn7ujokd"; - DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - - Assert.Equal(expectedAllocationPrice, model.AllocationPrice); - Assert.NotNull(model.Discounts); - Assert.Equal(expectedDiscounts.Count, model.Discounts.Count); - for (int i = 0; i < expectedDiscounts.Count; i++) - { - Assert.Equal(expectedDiscounts[i], model.Discounts[i]); - } - Assert.Equal(expectedEndDate, model.EndDate); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedMaximumAmount, model.MaximumAmount); - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); - Assert.Equal(expectedPrice, model.Price); - Assert.Equal(expectedPriceID, model.PriceID); - Assert.Equal(expectedStartDate, model.StartDate); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new Subscriptions::AddPrice - { - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ], - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - ExternalPriceID = "external_price_id", - MaximumAmount = "1.23", - MinimumAmount = "1.23", - PlanPhaseOrder = 0, - Price = new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }, - PriceID = "h74gfhdjvn7ujokd", - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new Subscriptions::AddPrice - { - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ], - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - ExternalPriceID = "external_price_id", - MaximumAmount = "1.23", - MinimumAmount = "1.23", - PlanPhaseOrder = 0, - Price = new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }, - PriceID = "h74gfhdjvn7ujokd", - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - NewAllocationPrice expectedAllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }; - List expectedDiscounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ]; - DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - string expectedExternalPriceID = "external_price_id"; - string expectedMaximumAmount = "1.23"; - string expectedMinimumAmount = "1.23"; - long expectedPlanPhaseOrder = 0; - Subscriptions::Price expectedPrice = new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string expectedPriceID = "h74gfhdjvn7ujokd"; - DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - - Assert.Equal(expectedAllocationPrice, deserialized.AllocationPrice); - Assert.NotNull(deserialized.Discounts); - Assert.Equal(expectedDiscounts.Count, deserialized.Discounts.Count); - for (int i = 0; i < expectedDiscounts.Count; i++) - { - Assert.Equal(expectedDiscounts[i], deserialized.Discounts[i]); - } - Assert.Equal(expectedEndDate, deserialized.EndDate); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedMaximumAmount, deserialized.MaximumAmount); - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - Assert.Equal(expectedPrice, deserialized.Price); - Assert.Equal(expectedPriceID, deserialized.PriceID); - Assert.Equal(expectedStartDate, deserialized.StartDate); - } - - [Fact] - public void Validation_Works() - { - var model = new Subscriptions::AddPrice - { - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ], - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - ExternalPriceID = "external_price_id", - MaximumAmount = "1.23", - MinimumAmount = "1.23", - PlanPhaseOrder = 0, - Price = new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }, - PriceID = "h74gfhdjvn7ujokd", - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new Subscriptions::AddPrice { }; - - Assert.Null(model.AllocationPrice); - Assert.False(model.RawData.ContainsKey("allocation_price")); - Assert.Null(model.Discounts); - Assert.False(model.RawData.ContainsKey("discounts")); - Assert.Null(model.EndDate); - Assert.False(model.RawData.ContainsKey("end_date")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.MaximumAmount); - Assert.False(model.RawData.ContainsKey("maximum_amount")); - Assert.Null(model.MinimumAmount); - Assert.False(model.RawData.ContainsKey("minimum_amount")); - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); - Assert.Null(model.Price); - Assert.False(model.RawData.ContainsKey("price")); - Assert.Null(model.PriceID); - Assert.False(model.RawData.ContainsKey("price_id")); - Assert.Null(model.StartDate); - Assert.False(model.RawData.ContainsKey("start_date")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::AddPrice { }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new Subscriptions::AddPrice - { - AllocationPrice = null, - Discounts = null, - EndDate = null, - ExternalPriceID = null, - MaximumAmount = null, - MinimumAmount = null, - PlanPhaseOrder = null, - Price = null, - PriceID = null, - StartDate = null, - }; - - Assert.Null(model.AllocationPrice); - Assert.True(model.RawData.ContainsKey("allocation_price")); - Assert.Null(model.Discounts); - Assert.True(model.RawData.ContainsKey("discounts")); - Assert.Null(model.EndDate); - Assert.True(model.RawData.ContainsKey("end_date")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.MaximumAmount); - Assert.True(model.RawData.ContainsKey("maximum_amount")); - Assert.Null(model.MinimumAmount); - Assert.True(model.RawData.ContainsKey("minimum_amount")); - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); - Assert.Null(model.Price); - Assert.True(model.RawData.ContainsKey("price")); - Assert.Null(model.PriceID); - Assert.True(model.RawData.ContainsKey("price_id")); - Assert.Null(model.StartDate); - Assert.True(model.RawData.ContainsKey("start_date")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new Subscriptions::AddPrice - { - AllocationPrice = null, - Discounts = null, - EndDate = null, - ExternalPriceID = null, - MaximumAmount = null, - MinimumAmount = null, - PlanPhaseOrder = null, - Price = null, - PriceID = null, - StartDate = null, - }; - - model.Validate(); - } -} - -public class PriceTest : TestBase -{ - [Fact] - public void NewSubscriptionUnitValidationWorks() - { - Subscriptions::Price value = new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionTieredValidationWorks() - { - Subscriptions::Price value = new Subscriptions::NewSubscriptionTieredPrice() - { - Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, - Name = "Annual fee", - TieredConfig = new() - { - Tiers = - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ], - Prorated = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionBulkValidationWorks() - { - Subscriptions::Price value = new Subscriptions::NewSubscriptionBulkPrice() - { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::ModelType.Bulk, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void BulkWithFiltersValidationWorks() - { - Subscriptions::Price value = new Subscriptions::BulkWithFilters() - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Subscriptions::Cadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionPackageValidationWorks() - { - Subscriptions::Price value = new Subscriptions::NewSubscriptionPackagePrice() - { - Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, - Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionMatrixValidationWorks() - { - Subscriptions::Price value = new Subscriptions::NewSubscriptionMatrixPrice() - { - Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, - ItemID = "item_id", - MatrixConfig = new() - { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], - }, - ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionThresholdTotalAmountValidationWorks() - { - Subscriptions::Price value = new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() - { - Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, - Name = "Annual fee", - ThresholdTotalAmountConfig = new() - { - ConsumptionTable = - [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - ], - Prorate = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionTieredPackageValidationWorks() - { - Subscriptions::Price value = new Subscriptions::NewSubscriptionTieredPackagePrice() - { - Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, - Name = "Annual fee", - TieredPackageConfig = new() - { - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionTieredWithMinimumValidationWorks() - { - Subscriptions::Price value = new Subscriptions::NewSubscriptionTieredWithMinimumPrice() - { - Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, - Name = "Annual fee", - TieredWithMinimumConfig = new() - { - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - HideZeroAmountTiers = true, - Prorate = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionGroupedTieredValidationWorks() - { - Subscriptions::Price value = new Subscriptions::NewSubscriptionGroupedTieredPrice() - { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() - { - GroupingKey = "x", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - }, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionTieredPackageWithMinimumValidationWorks() - { - Subscriptions::Price value = - new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() - { - Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, - Name = "Annual fee", - TieredPackageWithMinimumConfig = new() - { - PackageSize = 0, - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - ], - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionPackageWithAllocationValidationWorks() - { - Subscriptions::Price value = new Subscriptions::NewSubscriptionPackageWithAllocationPrice() - { - Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, - Name = "Annual fee", - PackageWithAllocationConfig = new() - { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionUnitWithPercentValidationWorks() - { - Subscriptions::Price value = new Subscriptions::NewSubscriptionUnitWithPercentPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, - Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionMatrixWithAllocationValidationWorks() - { - Subscriptions::Price value = new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() - { - Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, - ItemID = "item_id", - MatrixWithAllocationConfig = new() - { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], - }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void TieredWithProrationValidationWorks() - { - Subscriptions::Price value = new Subscriptions::TieredWithProration() - { - Cadence = Subscriptions::TieredWithProrationCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionUnitWithProrationValidationWorks() - { - Subscriptions::Price value = new Subscriptions::NewSubscriptionUnitWithProrationPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, - Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionGroupedAllocationValidationWorks() - { - Subscriptions::Price value = new Subscriptions::NewSubscriptionGroupedAllocationPrice() - { - Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionBulkWithProrationValidationWorks() - { - Subscriptions::Price value = new Subscriptions::NewSubscriptionBulkWithProrationPrice() - { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + AlignBillingWithSubscriptionStartDate = true, + AutoCollection = true, + AwsRegion = "aws_region", + BillingCycleAnchorConfiguration = new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + Day = 1, + Month = 1, + Year = 0, }, + CouponRedemptionCode = "coupon_redemption_code", + CreditsOverageRate = 0, + Currency = "currency", + CustomerID = "customer_id", + DefaultInvoiceMemo = "default_invoice_memo", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalCustomerID = "external_customer_id", + ExternalMarketplace = Subscriptions::ExternalMarketplace.Google, + ExternalMarketplaceReportingID = "external_marketplace_reporting_id", + ExternalPlanID = "ZMwNQefe7J3ecf7W", + Filter = "my_property > 100 AND my_other_property = 'bar'", + InitialPhaseOrder = 2, + InvoicingThreshold = "10.00", Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() - { - Subscriptions::Price value = - new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() - { - Cadence = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + Name = "name", + NetTerms = 0, + PerCreditOverageAmount = 0, + PlanID = "ZMwNQefe7J3ecf7W", + PlanVersionNumber = 0, + PriceOverrides = [JsonSerializer.Deserialize("{}")], + RemoveAdjustments = [new("h74gfhdjvn7ujokd")], + RemovePrices = + [ + new() { ExternalPriceID = "external_price_id", PriceID = "h74gfhdjvn7ujokd" }, + ], + ReplaceAdjustments = + [ + new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() - { - Subscriptions::Price value = - new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() - { - Cadence = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() + ], + ReplacePrices = + [ + new() { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() + { + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + Discounts = [ new() { - ScalingFactorValue = "scaling_factor", - ScalingValue = "scaling_value", + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, }, ], - ScalingKey = "scaling_key", - UnitAmounts = - [ - new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, - ], - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 2, + MaximumAmount = "1.23", + MinimumAmount = "1.23", + Price = new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = + SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + PriceID = "h74gfhdjvn7ujokd", }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + ], + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + TrialDurationDays = 0, + UsageCustomerIds = ["string"], + }; + + Subscriptions::SubscriptionCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); } +} +public class AddAdjustmentTest : TestBase +{ [Fact] - public void GroupedWithMinMaxThresholdsValidationWorks() + public void FieldRoundtrip_Works() { - Subscriptions::Price value = new Subscriptions::GroupedWithMinMaxThresholds() + var model = new Subscriptions::AddAdjustment { - Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() + Adjustment = new NewPercentageDiscount() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhaseOrder = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + Subscriptions::Adjustment expectedAdjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }; - value.Validate(); + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + long expectedPlanPhaseOrder = 0; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + + Assert.Equal(expectedAdjustment, model.Adjustment); + Assert.Equal(expectedEndDate, model.EndDate); + Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); + Assert.Equal(expectedStartDate, model.StartDate); } [Fact] - public void NewSubscriptionMatrixWithDisplayNameValidationWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::Price value = new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() + var model = new Subscriptions::AddAdjustment { - Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, - ItemID = "item_id", - MatrixWithDisplayNameConfig = new() + Adjustment = new NewPercentageDiscount() { - Dimension = "dimension", - UnitAmounts = + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = [ new() { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], }, ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhaseOrder = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }; - value.Validate(); + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewSubscriptionGroupedTieredPackageValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::Price value = new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() + var model = new Subscriptions::AddAdjustment { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, - GroupedTieredPackageConfig = new() + Adjustment = new NewPercentageDiscount() { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhaseOrder = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + Subscriptions::Adjustment expectedAdjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }; + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + long expectedPlanPhaseOrder = 0; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + + Assert.Equal(expectedAdjustment, deserialized.Adjustment); + Assert.Equal(expectedEndDate, deserialized.EndDate); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + Assert.Equal(expectedStartDate, deserialized.StartDate); + } + + [Fact] + public void Validation_Works() + { + var model = new Subscriptions::AddAdjustment + { + Adjustment = new NewPercentageDiscount() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhaseOrder = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewSubscriptionMaxGroupTieredPackageValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::Price value = new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + var model = new Subscriptions::AddAdjustment { - Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, - ItemID = "item_id", - MaxGroupTieredPackageConfig = new() + Adjustment = new NewPercentageDiscount() { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }, - ModelType = - Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", }; - value.Validate(); + + Assert.Null(model.EndDate); + Assert.False(model.RawData.ContainsKey("end_date")); + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.StartDate); + Assert.False(model.RawData.ContainsKey("start_date")); } [Fact] - public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Subscriptions::Price value = - new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + var model = new Subscriptions::AddAdjustment + { + Adjustment = new NewPercentageDiscount() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, - Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - UnitPrice = "unit_price", - Prorate = true, - SecondDimension = "second_dimension", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + }; + + model.Validate(); } [Fact] - public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Subscriptions::Price value = - new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + var model = new Subscriptions::AddAdjustment + { + Adjustment = new NewPercentageDiscount() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, - Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - SecondDimension = "second_dimension", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + + EndDate = null, + PlanPhaseOrder = null, + StartDate = null, + }; + + Assert.Null(model.EndDate); + Assert.True(model.RawData.ContainsKey("end_date")); + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.StartDate); + Assert.True(model.RawData.ContainsKey("start_date")); } [Fact] - public void NewSubscriptionCumulativeGroupedBulkValidationWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - Subscriptions::Price value = new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + var model = new Subscriptions::AddAdjustment { - Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() + Adjustment = new NewPercentageDiscount() { - DimensionValues = + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = [ new() { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], }, ], - Group = "group", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + + EndDate = null, + PlanPhaseOrder = null, + StartDate = null, }; - value.Validate(); + + model.Validate(); } +} +public class AdjustmentTest : TestBase +{ [Fact] - public void CumulativeGroupedAllocationValidationWorks() + public void NewPercentageDiscountValidationWorks() { - Subscriptions::Price value = new Subscriptions::CumulativeGroupedAllocation() + Subscriptions::Adjustment value = new NewPercentageDiscount() { - Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }; value.Validate(); } [Fact] - public void MinimumValidationWorks() + public void NewUsageDiscountValidationWorks() { - Subscriptions::Price value = new Subscriptions::Minimum() + Subscriptions::Adjustment value = new NewUsageDiscount() { - Cadence = Subscriptions::MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, + UsageDiscount = 0, + AppliesToAll = NewUsageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewUsageDiscountFilterField.PriceID, + Operator = NewUsageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewUsageDiscountPriceType.Usage, }; value.Validate(); } [Fact] - public void NewSubscriptionMinimumCompositeValidationWorks() + public void NewAmountDiscountValidationWorks() { - Subscriptions::Price value = new Subscriptions::NewSubscriptionMinimumCompositePrice() + Subscriptions::Adjustment value = new NewAmountDiscount() { - Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, - ItemID = "item_id", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = - Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, + AmountDiscount = "amount_discount", + AppliesToAll = AppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewAmountDiscountFilterField.PriceID, + Operator = NewAmountDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = PriceType.Usage, }; value.Validate(); } [Fact] - public void PercentValidationWorks() + public void NewMinimumValidationWorks() { - Subscriptions::Price value = new Subscriptions::Percent() + Subscriptions::Adjustment value = new NewMinimum() { - Cadence = Subscriptions::PercentCadence.Annual, + AdjustmentType = NewMinimumAdjustmentType.Minimum, ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + MinimumAmount = "minimum_amount", + AppliesToAll = NewMinimumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewMinimumFilterField.PriceID, + Operator = NewMinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMinimumPriceType.Usage, }; value.Validate(); } [Fact] - public void EventOutputValidationWorks() + public void NewMaximumValidationWorks() { - Subscriptions::Price value = new Subscriptions::EventOutput() + Subscriptions::Adjustment value = new NewMaximum() { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewMaximumAdjustmentType.Maximum, + MaximumAmount = "maximum_amount", + AppliesToAll = NewMaximumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewMaximumFilterField.PriceID, + Operator = NewMaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMaximumPriceType.Usage, }; value.Validate(); } [Fact] - public void NewSubscriptionUnitSerializationRoundtripWorks() + public void NewPercentageDiscountSerializationRoundtripWorks() { - Subscriptions::Price value = new Subscriptions::NewSubscriptionUnitPrice() + Subscriptions::Adjustment value = new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -4364,60 +2157,30 @@ public void NewSubscriptionUnitSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionTieredSerializationRoundtripWorks() + public void NewUsageDiscountSerializationRoundtripWorks() { - Subscriptions::Price value = new Subscriptions::NewSubscriptionTieredPrice() + Subscriptions::Adjustment value = new NewUsageDiscount() { - Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, - Name = "Annual fee", - TieredConfig = new() - { - Tiers = - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ], - Prorated = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, + UsageDiscount = 0, + AppliesToAll = NewUsageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewUsageDiscountFilterField.PriceID, + Operator = NewUsageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewUsageDiscountPriceType.Usage, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -4426,48 +2189,30 @@ public void NewSubscriptionTieredSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionBulkSerializationRoundtripWorks() + public void NewAmountDiscountSerializationRoundtripWorks() { - Subscriptions::Price value = new Subscriptions::NewSubscriptionBulkPrice() + Subscriptions::Adjustment value = new NewAmountDiscount() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::ModelType.Bulk, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, + AmountDiscount = "amount_discount", + AppliesToAll = AppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewAmountDiscountFilterField.PriceID, + Operator = NewAmountDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = PriceType.Usage, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -4476,55 +2221,31 @@ public void NewSubscriptionBulkSerializationRoundtripWorks() } [Fact] - public void BulkWithFiltersSerializationRoundtripWorks() + public void NewMinimumSerializationRoundtripWorks() { - Subscriptions::Price value = new Subscriptions::BulkWithFilters() + Subscriptions::Adjustment value = new NewMinimum() { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Subscriptions::Cadence.Annual, + AdjustmentType = NewMinimumAdjustmentType.Minimum, ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + MinimumAmount = "minimum_amount", + AppliesToAll = NewMinimumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewMinimumFilterField.PriceID, + Operator = NewMinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMinimumPriceType.Usage, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -4533,187 +2254,170 @@ public void BulkWithFiltersSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionPackageSerializationRoundtripWorks() + public void NewMaximumSerializationRoundtripWorks() { - Subscriptions::Price value = new Subscriptions::NewSubscriptionPackagePrice() + Subscriptions::Adjustment value = new NewMaximum() { - Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, - Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewMaximumAdjustmentType.Maximum, + MaximumAmount = "maximum_amount", + AppliesToAll = NewMaximumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewMaximumFilterField.PriceID, + Operator = NewMaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMaximumPriceType.Usage, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.Equal(value, deserialized); } +} +public class AddPriceTest : TestBase +{ [Fact] - public void NewSubscriptionMatrixSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - Subscriptions::Price value = new Subscriptions::NewSubscriptionMatrixPrice() + var model = new Subscriptions::AddPrice { - Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, - ItemID = "item_id", - MatrixConfig = new() - { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], - }, - ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + AllocationPrice = new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", }, + Discounts = + [ + new() + { + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, + }, + ], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + MaximumAmount = "1.23", + MinimumAmount = "1.23", + PlanPhaseOrder = 0, + Price = new Subscriptions::NewSubscriptionUnitPrice() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + PriceID = "h74gfhdjvn7ujokd", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - [Fact] - public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() - { - Subscriptions::Price value = new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + NewAllocationPrice expectedAllocationPrice = new() { - Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, - Name = "Annual fee", - ThresholdTotalAmountConfig = new() - { - ConsumptionTable = - [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - ], - Prorate = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + DurationUnit = CustomExpirationDurationUnit.Day, }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", + }; + List expectedDiscounts = + [ + new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewSubscriptionTieredPackageSerializationRoundtripWorks() - { - Subscriptions::Price value = new Subscriptions::NewSubscriptionTieredPackagePrice() + ]; + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedExternalPriceID = "external_price_id"; + string expectedMaximumAmount = "1.23"; + string expectedMinimumAmount = "1.23"; + long expectedPlanPhaseOrder = 0; + Subscriptions::Price expectedPrice = new Subscriptions::NewSubscriptionUnitPrice() { - Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", - TieredPackageConfig = new() - { - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], - }, + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4745,173 +2449,170 @@ public void NewSubscriptionTieredPackageSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + string expectedPriceID = "h74gfhdjvn7ujokd"; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Assert.Equal(value, deserialized); + Assert.Equal(expectedAllocationPrice, model.AllocationPrice); + Assert.NotNull(model.Discounts); + Assert.Equal(expectedDiscounts.Count, model.Discounts.Count); + for (int i = 0; i < expectedDiscounts.Count; i++) + { + Assert.Equal(expectedDiscounts[i], model.Discounts[i]); + } + Assert.Equal(expectedEndDate, model.EndDate); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedMaximumAmount, model.MaximumAmount); + Assert.Equal(expectedMinimumAmount, model.MinimumAmount); + Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); + Assert.Equal(expectedPrice, model.Price); + Assert.Equal(expectedPriceID, model.PriceID); + Assert.Equal(expectedStartDate, model.StartDate); } [Fact] - public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::Price value = new Subscriptions::NewSubscriptionTieredWithMinimumPrice() + var model = new Subscriptions::AddPrice { - Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, - Name = "Annual fee", - TieredWithMinimumConfig = new() + AllocationPrice = new() { - Tiers = + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = [ new() { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], }, ], - HideZeroAmountTiers = true, - Prorate = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", }, + Discounts = + [ + new() + { + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, + }, + ], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + MaximumAmount = "1.23", + MinimumAmount = "1.23", + PlanPhaseOrder = 0, + Price = new Subscriptions::NewSubscriptionUnitPrice() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + PriceID = "h74gfhdjvn7ujokd", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, ModelBase.SerializerOptions ); - Assert.Equal(value, deserialized); + Assert.Equal(model, deserialized); } [Fact] - public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::Price value = new Subscriptions::NewSubscriptionGroupedTieredPrice() + var model = new Subscriptions::AddPrice { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + AllocationPrice = new() { - GroupingKey = "x", - Tiers = + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", }, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, + Discounts = + [ + new() + { + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, + }, + ], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() - { - Subscriptions::Price value = - new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + MaximumAmount = "1.23", + MinimumAmount = "1.23", + PlanPhaseOrder = 0, + Price = new Subscriptions::NewSubscriptionUnitPrice() { - Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", - TieredPackageWithMinimumConfig = new() - { - PackageSize = 0, - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - ], - }, + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4942,139 +2643,63 @@ public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() }, Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() - { - Subscriptions::Price value = new Subscriptions::NewSubscriptionPackageWithAllocationPrice() - { - Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, - Name = "Annual fee", - PackageWithAllocationConfig = new() - { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + PriceID = "h74gfhdjvn7ujokd", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); + Assert.NotNull(deserialized); - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() - { - Subscriptions::Price value = new Subscriptions::NewSubscriptionUnitWithPercentPrice() + NewAllocationPrice expectedAllocationPrice = new() { - Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, - Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + DurationUnit = CustomExpirationDurationUnit.Day, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() - { - Subscriptions::Price value = new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() - { - Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], ItemID = "item_id", - MatrixWithAllocationConfig = new() + PerUnitCostBasis = "per_unit_cost_basis", + }; + List expectedDiscounts = + [ + new() { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, + ]; + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedExternalPriceID = "external_price_id"; + string expectedMaximumAmount = "1.23"; + string expectedMinimumAmount = "1.23"; + long expectedPlanPhaseOrder = 0; + Subscriptions::Price expectedPrice = new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5106,189 +2731,221 @@ public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + string expectedPriceID = "h74gfhdjvn7ujokd"; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Assert.Equal(value, deserialized); + Assert.Equal(expectedAllocationPrice, deserialized.AllocationPrice); + Assert.NotNull(deserialized.Discounts); + Assert.Equal(expectedDiscounts.Count, deserialized.Discounts.Count); + for (int i = 0; i < expectedDiscounts.Count; i++) + { + Assert.Equal(expectedDiscounts[i], deserialized.Discounts[i]); + } + Assert.Equal(expectedEndDate, deserialized.EndDate); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedMaximumAmount, deserialized.MaximumAmount); + Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + Assert.Equal(expectedPrice, deserialized.Price); + Assert.Equal(expectedPriceID, deserialized.PriceID); + Assert.Equal(expectedStartDate, deserialized.StartDate); } [Fact] - public void TieredWithProrationSerializationRoundtripWorks() + public void Validation_Works() { - Subscriptions::Price value = new Subscriptions::TieredWithProration() + var model = new Subscriptions::AddPrice { - Cadence = Subscriptions::TieredWithProrationCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + AllocationPrice = new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", }, + Discounts = + [ + new() + { + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, + }, + ], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + MaximumAmount = "1.23", + MinimumAmount = "1.23", + PlanPhaseOrder = 0, + Price = new Subscriptions::NewSubscriptionUnitPrice() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + PriceID = "h74gfhdjvn7ujokd", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::Price value = new Subscriptions::NewSubscriptionUnitWithProrationPrice() + var model = new Subscriptions::AddPrice { }; + + Assert.Null(model.AllocationPrice); + Assert.False(model.RawData.ContainsKey("allocation_price")); + Assert.Null(model.Discounts); + Assert.False(model.RawData.ContainsKey("discounts")); + Assert.Null(model.EndDate); + Assert.False(model.RawData.ContainsKey("end_date")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.MaximumAmount); + Assert.False(model.RawData.ContainsKey("maximum_amount")); + Assert.Null(model.MinimumAmount); + Assert.False(model.RawData.ContainsKey("minimum_amount")); + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.Price); + Assert.False(model.RawData.ContainsKey("price")); + Assert.Null(model.PriceID); + Assert.False(model.RawData.ContainsKey("price_id")); + Assert.Null(model.StartDate); + Assert.False(model.RawData.ContainsKey("start_date")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Subscriptions::AddPrice { }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Subscriptions::AddPrice { - Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, - Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AllocationPrice = null, + Discounts = null, + EndDate = null, + ExternalPriceID = null, + MaximumAmount = null, + MinimumAmount = null, + PlanPhaseOrder = null, + Price = null, + PriceID = null, + StartDate = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.AllocationPrice); + Assert.True(model.RawData.ContainsKey("allocation_price")); + Assert.Null(model.Discounts); + Assert.True(model.RawData.ContainsKey("discounts")); + Assert.Null(model.EndDate); + Assert.True(model.RawData.ContainsKey("end_date")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.MaximumAmount); + Assert.True(model.RawData.ContainsKey("maximum_amount")); + Assert.Null(model.MinimumAmount); + Assert.True(model.RawData.ContainsKey("minimum_amount")); + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.Price); + Assert.True(model.RawData.ContainsKey("price")); + Assert.Null(model.PriceID); + Assert.True(model.RawData.ContainsKey("price_id")); + Assert.Null(model.StartDate); + Assert.True(model.RawData.ContainsKey("start_date")); } [Fact] - public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - Subscriptions::Price value = new Subscriptions::NewSubscriptionGroupedAllocationPrice() + var model = new Subscriptions::AddPrice { - Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AllocationPrice = null, + Discounts = null, + EndDate = null, + ExternalPriceID = null, + MaximumAmount = null, + MinimumAmount = null, + PlanPhaseOrder = null, + Price = null, + PriceID = null, + StartDate = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } +} +public class PriceTest : TestBase +{ [Fact] - public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() + public void NewSubscriptionUnitValidationWorks() { - Subscriptions::Price value = new Subscriptions::NewSubscriptionBulkWithProrationPrice() + Subscriptions::Price value = new Subscriptions::NewSubscriptionUnitPrice() { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5320,159 +2977,31 @@ public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks() - { - Subscriptions::Price value = - new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() - { - Cadence = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks() - { - Subscriptions::Price value = - new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() - { - Cadence = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() - { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = - [ - new() - { - ScalingFactorValue = "scaling_factor", - ScalingValue = "scaling_value", - }, - ], - ScalingKey = "scaling_key", - UnitAmounts = - [ - new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, - ], - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() - { - Subscriptions::Price value = new Subscriptions::GroupedWithMinMaxThresholds() - { - Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + public void NewSubscriptionTieredValidationWorks() + { + Subscriptions::Price value = new Subscriptions::NewSubscriptionTieredPrice() + { + Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, Name = "Annual fee", + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5504,37 +3033,18 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() + public void NewSubscriptionBulkValidationWorks() { - Subscriptions::Price value = new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() + Subscriptions::Price value = new Subscriptions::NewSubscriptionBulkPrice() { - Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, ItemID = "item_id", - MatrixWithDisplayNameConfig = new() - { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + ModelType = Subscriptions::ModelType.Bulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5567,34 +3077,25 @@ public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() + public void BulkWithFiltersValidationWorks() { - Subscriptions::Price value = new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() + Subscriptions::Price value = new Subscriptions::BulkWithFilters() { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, - GroupedTieredPackageConfig = new() + BulkWithFiltersConfig = new() { - GroupingKey = "x", - PackageSize = "package_size", + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], Tiers = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, + Cadence = Subscriptions::Cadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5627,35 +3128,19 @@ public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() + public void NewSubscriptionPackageValidationWorks() { - Subscriptions::Price value = new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + Subscriptions::Price value = new Subscriptions::NewSubscriptionPackagePrice() { - Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, ItemID = "item_id", - MaxGroupTieredPackageConfig = new() - { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5687,177 +3172,77 @@ public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWorks() - { - Subscriptions::Price value = - new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() - { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, - Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - UnitPrice = "unit_price", - Prorate = true, - SecondDimension = "second_dimension", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void NewSubscriptionMatrixValidationWorks() { - Subscriptions::Price value = - new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + Subscriptions::Price value = new Subscriptions::NewSubscriptionMatrixPrice() + { + Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, + ItemID = "item_id", + MatrixConfig = new() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, - Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - SecondDimension = "second_dimension", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } [Fact] - public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() + public void NewSubscriptionThresholdTotalAmountValidationWorks() { - Subscriptions::Price value = new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + Subscriptions::Price value = new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() { - Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() + Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + Name = "Annual fee", + ThresholdTotalAmountConfig = new() { - DimensionValues = + ConsumptionTable = [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, ], - Group = "group", + Prorate = true, }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5889,30 +3274,27 @@ public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void CumulativeGroupedAllocationSerializationRoundtripWorks() + public void NewSubscriptionTieredPackageValidationWorks() { - Subscriptions::Price value = new Subscriptions::CumulativeGroupedAllocation() + Subscriptions::Price value = new Subscriptions::NewSubscriptionTieredPackagePrice() { - Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, Name = "Annual fee", + TieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5944,24 +3326,39 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void MinimumSerializationRoundtripWorks() + public void NewSubscriptionTieredWithMinimumValidationWorks() { - Subscriptions::Price value = new Subscriptions::Minimum() + Subscriptions::Price value = new Subscriptions::NewSubscriptionTieredWithMinimumPrice() { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = + Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, Name = "Annual fee", + TieredWithMinimumConfig = new() + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + HideZeroAmountTiers = true, + Prorate = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5993,25 +3390,26 @@ public void MinimumSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() + public void NewSubscriptionGroupedTieredValidationWorks() { - Subscriptions::Price value = new Subscriptions::NewSubscriptionMinimumCompositePrice() + Subscriptions::Price value = new Subscriptions::NewSubscriptionGroupedTieredPrice() { - Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, + GroupedTieredConfig = new() + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, ItemID = "item_id", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = - Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, + ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -6044,24 +3442,89 @@ public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + value.Validate(); + } - Assert.Equal(value, deserialized); + [Fact] + public void NewSubscriptionTieredPackageWithMinimumValidationWorks() + { + Subscriptions::Price value = + new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + { + Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + Name = "Annual fee", + TieredPackageWithMinimumConfig = new() + { + PackageSize = 0, + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + ], + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } [Fact] - public void PercentSerializationRoundtripWorks() + public void NewSubscriptionPackageWithAllocationValidationWorks() { - Subscriptions::Price value = new Subscriptions::Percent() + Subscriptions::Price value = new Subscriptions::NewSubscriptionPackageWithAllocationPrice() { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, Name = "Annual fee", - PercentConfig = new(0), + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6093,29 +3556,19 @@ public void PercentSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void EventOutputSerializationRoundtripWorks() + public void NewSubscriptionUnitWithPercentValidationWorks() { - Subscriptions::Price value = new Subscriptions::EventOutput() - { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Subscriptions::Price value = new Subscriptions::NewSubscriptionUnitWithPercentPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6147,34 +3600,25 @@ public void EventOutputSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } -} -public class BulkWithFiltersTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionMatrixWithAllocationValidationWorks() { - var model = new Subscriptions::BulkWithFilters + Subscriptions::Price value = new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() { - BulkWithFiltersConfig = new() + Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, + ItemID = "item_id", + MatrixWithAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Cadence = Subscriptions::Cadence.Annual, - ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -6207,96 +3651,20 @@ public void FieldRoundtrip_Works() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - - Subscriptions::BulkWithFiltersConfig expectedBulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - ApiEnum expectedCadence = Subscriptions::Cadence.Annual; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::ConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedBulkWithFiltersConfig, model.BulkWithFiltersConfig); - Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedItemID, model.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); - Assert.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); + value.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void TieredWithProrationValidationWorks() { - var model = new Subscriptions::BulkWithFilters + Subscriptions::Price value = new Subscriptions::TieredWithProration() { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Subscriptions::Cadence.Annual, + Cadence = Subscriptions::TieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6328,33 +3696,20 @@ public void SerializationRoundtrip_Works() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + value.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewSubscriptionUnitWithProrationValidationWorks() { - var model = new Subscriptions::BulkWithFilters + Subscriptions::Price value = new Subscriptions::NewSubscriptionUnitWithProrationPrice() { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Subscriptions::Cadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6386,105 +3741,24 @@ public void FieldRoundtripThroughSerialization_Works() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - Subscriptions::BulkWithFiltersConfig expectedBulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - ApiEnum expectedCadence = Subscriptions::Cadence.Annual; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::ConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedBulkWithFiltersConfig, deserialized.BulkWithFiltersConfig); - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + value.Validate(); } [Fact] - public void Validation_Works() + public void NewSubscriptionGroupedAllocationValidationWorks() { - var model = new Subscriptions::BulkWithFilters + Subscriptions::Price value = new Subscriptions::NewSubscriptionGroupedAllocationPrice() { - BulkWithFiltersConfig = new() + Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", }, - Cadence = Subscriptions::Cadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -6517,553 +3791,821 @@ public void Validation_Works() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - - model.Validate(); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void NewSubscriptionBulkWithProrationValidationWorks() { - var model = new Subscriptions::BulkWithFilters + Subscriptions::Price value = new Subscriptions::NewSubscriptionBulkWithProrationPrice() { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = + BulkWithProrationConfig = new( [ new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Subscriptions::Cadence.Annual, + ] + ), + Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, Name = "Annual fee", - }; - - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.False(model.RawData.ContainsKey("reference_id")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::BulkWithFilters - { - BulkWithFiltersConfig = new() + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, - Cadence = Subscriptions::Cadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new Subscriptions::BulkWithFilters - { - BulkWithFiltersConfig = new() + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }, - Cadence = Subscriptions::Cadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; - - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.True(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.True(model.RawData.ContainsKey("reference_id")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new Subscriptions::BulkWithFilters - { - BulkWithFiltersConfig = new() + Currency = "currency", + DimensionalPriceConfiguration = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", }, - Cadence = Subscriptions::Cadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - model.Validate(); + value.Validate(); } -} -public class BulkWithFiltersConfigTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() { - var model = new Subscriptions::BulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - List expectedFilters = - [ - new() { PropertyKey = "x", PropertyValue = "x" }, - ]; - List expectedTiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ]; - - Assert.Equal(expectedFilters.Count, model.Filters.Count); - for (int i = 0; i < expectedFilters.Count; i++) - { - Assert.Equal(expectedFilters[i], model.Filters[i]); - } - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } + Subscriptions::Price value = + new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + { + Cadence = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() { - var model = new Subscriptions::BulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + Subscriptions::Price value = + new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() + { + Cadence = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, + GroupedWithMeteredMinimumConfig = new() + { + GroupingKey = "x", + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = + [ + new() + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }, + ], + ScalingKey = "scaling_key", + UnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, + ], + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void GroupedWithMinMaxThresholdsValidationWorks() { - var model = new Subscriptions::BulkWithFiltersConfig + Subscriptions::Price value = new Subscriptions::GroupedWithMinMaxThresholds() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - List expectedFilters = - [ - new() { PropertyKey = "x", PropertyValue = "x" }, - ]; - List expectedTiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ]; - - Assert.Equal(expectedFilters.Count, deserialized.Filters.Count); - for (int i = 0; i < expectedFilters.Count; i++) - { - Assert.Equal(expectedFilters[i], deserialized.Filters[i]); - } - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); - } + value.Validate(); } [Fact] - public void Validation_Works() + public void NewSubscriptionMatrixWithDisplayNameValidationWorks() { - var model = new Subscriptions::BulkWithFiltersConfig + Subscriptions::Price value = new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - model.Validate(); - } -} - -public class FilterTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new Subscriptions::Filter { PropertyKey = "x", PropertyValue = "x" }; - - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; - - Assert.Equal(expectedPropertyKey, model.PropertyKey); - Assert.Equal(expectedPropertyValue, model.PropertyValue); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new Subscriptions::Filter { PropertyKey = "x", PropertyValue = "x" }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, + ItemID = "item_id", + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewSubscriptionGroupedTieredPackageValidationWorks() { - var model = new Subscriptions::Filter { PropertyKey = "x", PropertyValue = "x" }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; - - Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); - Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); + Subscriptions::Price value = new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() + { + Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, + GroupedTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } [Fact] - public void Validation_Works() + public void NewSubscriptionMaxGroupTieredPackageValidationWorks() { - var model = new Subscriptions::Filter { PropertyKey = "x", PropertyValue = "x" }; - - model.Validate(); + Subscriptions::Price value = new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + { + Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, + ItemID = "item_id", + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } -} -public class TierTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() { - var model = new Subscriptions::Tier - { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", - }; - - string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; - - Assert.Equal(expectedUnitAmount, model.UnitAmount); - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Subscriptions::Price value = + new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + { + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + Prorate = true, + SecondDimension = "second_dimension", + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() { - var model = new Subscriptions::Tier - { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + Subscriptions::Price value = + new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + { + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + Name = "Annual fee", + ScalableMatrixWithTieredPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + SecondDimension = "second_dimension", + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewSubscriptionCumulativeGroupedBulkValidationWorks() { - var model = new Subscriptions::Tier + Subscriptions::Price value = new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; - - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + value.Validate(); } [Fact] - public void Validation_Works() + public void CumulativeGroupedAllocationValidationWorks() { - var model = new Subscriptions::Tier + Subscriptions::Price value = new Subscriptions::CumulativeGroupedAllocation() { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new Subscriptions::Tier { UnitAmount = "unit_amount" }; - - Assert.Null(model.TierLowerBound); - Assert.False(model.RawData.ContainsKey("tier_lower_bound")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::Tier { UnitAmount = "unit_amount" }; - - model.Validate(); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void NewSubscriptionMinimumCompositeValidationWorks() { - var model = new Subscriptions::Tier + Subscriptions::Price value = new Subscriptions::NewSubscriptionMinimumCompositePrice() { - UnitAmount = "unit_amount", - - TierLowerBound = null, + Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, + ItemID = "item_id", + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = + Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - Assert.Null(model.TierLowerBound); - Assert.True(model.RawData.ContainsKey("tier_lower_bound")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void PercentValidationWorks() { - var model = new Subscriptions::Tier + Subscriptions::Price value = new Subscriptions::Percent() { - UnitAmount = "unit_amount", - - TierLowerBound = null, - }; - - model.Validate(); - } -} - -public class CadenceTest : TestBase -{ - [Theory] - [InlineData(Subscriptions::Cadence.Annual)] - [InlineData(Subscriptions::Cadence.SemiAnnual)] - [InlineData(Subscriptions::Cadence.Monthly)] - [InlineData(Subscriptions::Cadence.Quarterly)] - [InlineData(Subscriptions::Cadence.OneTime)] - [InlineData(Subscriptions::Cadence.Custom)] - public void Validation_Works(Subscriptions::Cadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + Cadence = Subscriptions::PercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; value.Validate(); } [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(Subscriptions::Cadence.Annual)] - [InlineData(Subscriptions::Cadence.SemiAnnual)] - [InlineData(Subscriptions::Cadence.Monthly)] - [InlineData(Subscriptions::Cadence.Quarterly)] - [InlineData(Subscriptions::Cadence.OneTime)] - [InlineData(Subscriptions::Cadence.Custom)] - public void SerializationRoundtrip_Works(Subscriptions::Cadence rawValue) + public void EventOutputValidationWorks() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + Subscriptions::Price value = new Subscriptions::EventOutput() + { + Cadence = Subscriptions::EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void NewSubscriptionUnitSerializationRoundtripWorks() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, + Subscriptions::Price value = new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, ModelBase.SerializerOptions ); Assert.Equal(value, deserialized); } -} - -public class ConversionRateConfigTest : TestBase -{ - [Fact] - public void UnitValidationWorks() - { - Subscriptions::ConversionRateConfig value = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); - } [Fact] - public void TieredValidationWorks() + public void NewSubscriptionTieredSerializationRoundtripWorks() { - Subscriptions::ConversionRateConfig value = new SharedTieredConversionRateConfig() + Subscriptions::Price value = new Subscriptions::NewSubscriptionTieredPrice() { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( + Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, + Name = "Annual fee", + TieredConfig = new() + { + Tiers = [ new() { @@ -7071,22 +4613,92 @@ public void TieredValidationWorks() UnitAmount = "unit_amount", LastUnit = 0, }, - ] - ), + ], + Prorated = true, + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void UnitSerializationRoundtripWorks() + public void NewSubscriptionBulkSerializationRoundtripWorks() { - Subscriptions::ConversionRateConfig value = new SharedUnitConversionRateConfig() + Subscriptions::Price value = new Subscriptions::NewSubscriptionBulkPrice() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::ModelType.Bulk, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -7095,45 +4707,72 @@ public void UnitSerializationRoundtripWorks() } [Fact] - public void TieredSerializationRoundtripWorks() + public void BulkWithFiltersSerializationRoundtripWorks() { - Subscriptions::ConversionRateConfig value = new SharedTieredConversionRateConfig() + Subscriptions::Price value = new Subscriptions::BulkWithFilters() { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = Subscriptions::Cadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.Equal(value, deserialized); } -} -public class TieredWithProrationTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionPackageSerializationRoundtripWorks() { - var model = new Subscriptions::TieredWithProration + Subscriptions::Price value = new Subscriptions::NewSubscriptionPackagePrice() { - Cadence = Subscriptions::TieredWithProrationCadence.Annual, + Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -7165,85 +4804,30 @@ public void FieldRoundtrip_Works() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - - ApiEnum expectedCadence = - Subscriptions::TieredWithProrationCadence.Annual; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); - string expectedName = "Annual fee"; - Subscriptions::TieredWithProrationConfig expectedTieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions ); - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::TieredWithProrationConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedItemID, model.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); - Assert.Equal(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); - Assert.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); + Assert.Equal(value, deserialized); } [Fact] - public void SerializationRoundtrip_Works() + public void NewSubscriptionMatrixSerializationRoundtripWorks() { - var model = new Subscriptions::TieredWithProration + Subscriptions::Price value = new Subscriptions::NewSubscriptionMatrixPrice() { - Cadence = Subscriptions::TieredWithProrationCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, ItemID = "item_id", + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -7275,27 +4859,34 @@ public void SerializationRoundtrip_Works() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, ModelBase.SerializerOptions ); - Assert.Equal(model, deserialized); + Assert.Equal(value, deserialized); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() { - var model = new Subscriptions::TieredWithProration + Subscriptions::Price value = new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() { - Cadence = Subscriptions::TieredWithProrationCadence.Annual, + Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -7327,95 +4918,33 @@ public void FieldRoundtripThroughSerialization_Works() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); - Assert.NotNull(deserialized); - - ApiEnum expectedCadence = - Subscriptions::TieredWithProrationCadence.Annual; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); - string expectedName = "Annual fee"; - Subscriptions::TieredWithProrationConfig expectedTieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ); - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::TieredWithProrationConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void NewSubscriptionTieredPackageSerializationRoundtripWorks() { - var model = new Subscriptions::TieredWithProration + Subscriptions::Price value = new Subscriptions::NewSubscriptionTieredPackagePrice() { - Cadence = Subscriptions::TieredWithProrationCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + TieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -7447,464 +4976,493 @@ public void Validation_Works() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new Subscriptions::TieredWithProration - { - Cadence = Subscriptions::TieredWithProrationCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), - }; - - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.False(model.RawData.ContainsKey("reference_id")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::TieredWithProration - { - Cadence = Subscriptions::TieredWithProrationCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new Subscriptions::TieredWithProration - { - Cadence = Subscriptions::TieredWithProrationCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; - - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.True(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.True(model.RawData.ContainsKey("reference_id")); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() { - var model = new Subscriptions::TieredWithProration + Subscriptions::Price value = new Subscriptions::NewSubscriptionTieredWithMinimumPrice() { - Cadence = Subscriptions::TieredWithProrationCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; - - model.Validate(); - } -} - -public class TieredWithProrationCadenceTest : TestBase -{ - [Theory] - [InlineData(Subscriptions::TieredWithProrationCadence.Annual)] - [InlineData(Subscriptions::TieredWithProrationCadence.SemiAnnual)] - [InlineData(Subscriptions::TieredWithProrationCadence.Monthly)] - [InlineData(Subscriptions::TieredWithProrationCadence.Quarterly)] - [InlineData(Subscriptions::TieredWithProrationCadence.OneTime)] - [InlineData(Subscriptions::TieredWithProrationCadence.Custom)] - public void Validation_Works(Subscriptions::TieredWithProrationCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(Subscriptions::TieredWithProrationCadence.Annual)] - [InlineData(Subscriptions::TieredWithProrationCadence.SemiAnnual)] - [InlineData(Subscriptions::TieredWithProrationCadence.Monthly)] - [InlineData(Subscriptions::TieredWithProrationCadence.Quarterly)] - [InlineData(Subscriptions::TieredWithProrationCadence.OneTime)] - [InlineData(Subscriptions::TieredWithProrationCadence.Custom)] - public void SerializationRoundtrip_Works(Subscriptions::TieredWithProrationCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } -} - -public class TieredWithProrationConfigTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new Subscriptions::TieredWithProrationConfig - { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], - }; - - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; - - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new Subscriptions::TieredWithProrationConfig - { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + TieredWithMinimumConfig = new() + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + HideZeroAmountTiers = true, + Prorate = true, + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, ModelBase.SerializerOptions ); - Assert.Equal(model, deserialized); + Assert.Equal(value, deserialized); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() { - var model = new Subscriptions::TieredWithProrationConfig + Subscriptions::Price value = new Subscriptions::NewSubscriptionGroupedTieredPrice() { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, + GroupedTieredConfig = new() + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); - Assert.NotNull(deserialized); - - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; - - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); - } - } - - [Fact] - public void Validation_Works() - { - var model = new Subscriptions::TieredWithProrationConfig - { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], - }; - model.Validate(); + Assert.Equal(value, deserialized); } -} -public class TieredWithProrationConfigTierTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() { - var model = new Subscriptions::TieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; - - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + Subscriptions::Price value = + new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + { + Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + Name = "Annual fee", + TieredPackageWithMinimumConfig = new() + { + PackageSize = 0, + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + ], + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(value, deserialized); } [Fact] - public void SerializationRoundtrip_Works() + public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() { - var model = new Subscriptions::TieredWithProrationConfigTier + Subscriptions::Price value = new Subscriptions::NewSubscriptionPackageWithAllocationPrice() { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, ModelBase.SerializerOptions ); - Assert.Equal(model, deserialized); + Assert.Equal(value, deserialized); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() { - var model = new Subscriptions::TieredWithProrationConfigTier + Subscriptions::Price value = new Subscriptions::NewSubscriptionUnitWithPercentPrice() { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); - Assert.NotNull(deserialized); - - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() { - var model = new Subscriptions::TieredWithProrationConfigTier + Subscriptions::Price value = new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; - - model.Validate(); - } -} - -public class TieredWithProrationConversionRateConfigTest : TestBase -{ - [Fact] - public void UnitValidationWorks() - { - Subscriptions::TieredWithProrationConversionRateConfig value = - new SharedUnitConversionRateConfig() + Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, + ItemID = "item_id", + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ModelType = + Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() - { - Subscriptions::TieredWithProrationConversionRateConfig value = - new SharedTieredConversionRateConfig() + }, + Currency = "currency", + DimensionalPriceConfiguration = new() { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void UnitSerializationRoundtripWorks() + public void TieredWithProrationSerializationRoundtripWorks() { - Subscriptions::TieredWithProrationConversionRateConfig value = - new SharedUnitConversionRateConfig() + Subscriptions::Price value = new Subscriptions::TieredWithProration() + { + Cadence = Subscriptions::TieredWithProrationCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), - }; + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } [Fact] - public void TieredSerializationRoundtripWorks() + public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() { - Subscriptions::TieredWithProrationConversionRateConfig value = - new SharedTieredConversionRateConfig() + Subscriptions::Price value = new Subscriptions::NewSubscriptionUnitWithProrationPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } -} -public class GroupedWithMinMaxThresholdsTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() { - var model = new Subscriptions::GroupedWithMinMaxThresholds + Subscriptions::Price value = new Subscriptions::NewSubscriptionGroupedAllocationPrice() { - Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() { + Allocation = "allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + OverageUnitRate = "overage_unit_rate", }, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7937,98 +5495,30 @@ public void FieldRoundtrip_Works() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - - ApiEnum expectedCadence = - Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual; - Subscriptions::GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = - new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal( - expectedGroupedWithMinMaxThresholdsConfig, - model.GroupedWithMinMaxThresholdsConfig + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions ); - Assert.Equal(expectedItemID, model.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); - Assert.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); + Assert.Equal(value, deserialized); } [Fact] - public void SerializationRoundtrip_Works() + public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() { - var model = new Subscriptions::GroupedWithMinMaxThresholds + Subscriptions::Price value = new Subscriptions::NewSubscriptionBulkWithProrationPrice() { - Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -8061,20 +5551,148 @@ public void SerializationRoundtrip_Works() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks() + { + Subscriptions::Price value = + new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + { + Cadence = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, ModelBase.SerializerOptions ); - Assert.Equal(model, deserialized); + Assert.Equal(value, deserialized); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks() + { + Subscriptions::Price value = + new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() + { + Cadence = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, + GroupedWithMeteredMinimumConfig = new() + { + GroupingKey = "x", + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = + [ + new() + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }, + ], + ScalingKey = "scaling_key", + UnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, + ], + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() { - var model = new Subscriptions::GroupedWithMinMaxThresholds + Subscriptions::Price value = new Subscriptions::GroupedWithMinMaxThresholds() { Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, GroupedWithMinMaxThresholdsConfig = new() @@ -8117,108 +5735,37 @@ public void FieldRoundtripThroughSerialization_Works() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); - Assert.NotNull(deserialized); - - ApiEnum expectedCadence = - Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual; - Subscriptions::GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = - new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal( - expectedGroupedWithMinMaxThresholdsConfig, - deserialized.GroupedWithMinMaxThresholdsConfig - ); - Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() { - var model = new Subscriptions::GroupedWithMinMaxThresholds + Subscriptions::Price value = new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() { - Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, + ItemID = "item_id", + MatrixWithDisplayNameConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], }, - ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -8251,421 +5798,564 @@ public void Validation_Works() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - model.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() { - var model = new Subscriptions::GroupedWithMinMaxThresholds + Subscriptions::Price value = new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() { - Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, + GroupedTieredPackageConfig = new() { GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], }, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", - }; - - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.False(model.RawData.ContainsKey("reference_id")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::GroupedWithMinMaxThresholds - { - Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, - ItemID = "item_id", - Name = "Annual fee", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new Subscriptions::GroupedWithMinMaxThresholds - { - Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }, - ItemID = "item_id", - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; - - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.True(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.True(model.RawData.ContainsKey("reference_id")); + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() { - var model = new Subscriptions::GroupedWithMinMaxThresholds + Subscriptions::Price value = new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() { - Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, + ItemID = "item_id", + MaxGroupTieredPackageConfig = new() { GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], }, - ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - model.Validate(); - } -} - -public class GroupedWithMinMaxThresholdsCadenceTest : TestBase -{ - [Theory] - [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Custom)] - public void Validation_Works(Subscriptions::GroupedWithMinMaxThresholdsCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Custom)] - public void SerializationRoundtrip_Works( - Subscriptions::GroupedWithMinMaxThresholdsCadence rawValue - ) + public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWorks() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + Subscriptions::Price value = + new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + { + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + Prorate = true, + SecondDimension = "second_dimension", + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtripWorks() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + Subscriptions::Price value = + new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + { + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + Name = "Annual fee", + ScalableMatrixWithTieredPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + SecondDimension = "second_dimension", + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } -} - -public class GroupedWithMinMaxThresholdsConfigTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new Subscriptions::GroupedWithMinMaxThresholdsConfig - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; - - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; - - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); - } [Fact] - public void SerializationRoundtrip_Works() + public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() { - var model = new Subscriptions::GroupedWithMinMaxThresholdsConfig + Subscriptions::Price value = new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + Assert.Equal(value, deserialized); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void CumulativeGroupedAllocationSerializationRoundtripWorks() { - var model = new Subscriptions::GroupedWithMinMaxThresholdsConfig + Subscriptions::Price value = new Subscriptions::CumulativeGroupedAllocation() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; - - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); - Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); - Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() { - var model = new Subscriptions::GroupedWithMinMaxThresholdsConfig + Subscriptions::Price value = new Subscriptions::NewSubscriptionMinimumCompositePrice() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; - - model.Validate(); - } -} - -public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase -{ - [Fact] - public void UnitValidationWorks() - { - Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig value = - new SharedUnitConversionRateConfig() + Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, + ItemID = "item_id", + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = + Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() - { - Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig value = - new SharedTieredConversionRateConfig() + }, + Currency = "currency", + DimensionalPriceConfiguration = new() { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void UnitSerializationRoundtripWorks() + public void PercentSerializationRoundtripWorks() { - Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig value = - new SharedUnitConversionRateConfig() + Subscriptions::Price value = new Subscriptions::Percent() + { + Cadence = Subscriptions::PercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), - }; + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } [Fact] - public void TieredSerializationRoundtripWorks() + public void EventOutputSerializationRoundtripWorks() { - Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig value = - new SharedTieredConversionRateConfig() + Subscriptions::Price value = new Subscriptions::EventOutput() + { + Cadence = Subscriptions::EventOutputCadence.Annual, + EventOutputConfig = new() { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class CumulativeGroupedAllocationTest : TestBase +public class BulkWithFiltersTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::CumulativeGroupedAllocation + var model = new Subscriptions::BulkWithFilters { - Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + BulkWithFiltersConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }, + Cadence = Subscriptions::Cadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -8700,20 +6390,18 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - Subscriptions::CumulativeGroupedAllocationCadence.Annual; - Subscriptions::CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = - new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + Subscriptions::BulkWithFiltersConfig expectedBulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + ApiEnum expectedCadence = Subscriptions::Cadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -8723,7 +6411,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::ConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8747,11 +6435,8 @@ public void FieldRoundtrip_Works() Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; + Assert.Equal(expectedBulkWithFiltersConfig, model.BulkWithFiltersConfig); Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal( - expectedCumulativeGroupedAllocationConfig, - model.CumulativeGroupedAllocationConfig - ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); @@ -8780,16 +6465,18 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::CumulativeGroupedAllocation + var model = new Subscriptions::BulkWithFilters { - Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + BulkWithFiltersConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }, + Cadence = Subscriptions::Cadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -8825,7 +6512,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -8836,16 +6523,18 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::CumulativeGroupedAllocation + var model = new Subscriptions::BulkWithFilters { - Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + BulkWithFiltersConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }, + Cadence = Subscriptions::Cadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -8881,26 +6570,24 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = - Subscriptions::CumulativeGroupedAllocationCadence.Annual; - Subscriptions::CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = - new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + Subscriptions::BulkWithFiltersConfig expectedBulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + ApiEnum expectedCadence = Subscriptions::Cadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -8910,7 +6597,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::ConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8934,11 +6621,8 @@ public void FieldRoundtripThroughSerialization_Works() Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; + Assert.Equal(expectedBulkWithFiltersConfig, deserialized.BulkWithFiltersConfig); Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal( - expectedCumulativeGroupedAllocationConfig, - deserialized.CumulativeGroupedAllocationConfig - ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); @@ -8970,16 +6654,18 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::CumulativeGroupedAllocation + var model = new Subscriptions::BulkWithFilters { - Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + BulkWithFiltersConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }, + Cadence = Subscriptions::Cadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -9020,16 +6706,18 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::CumulativeGroupedAllocation + var model = new Subscriptions::BulkWithFilters { - Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + BulkWithFiltersConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }, + Cadence = Subscriptions::Cadence.Annual, ItemID = "item_id", Name = "Annual fee", }; @@ -9065,16 +6753,18 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::CumulativeGroupedAllocation + var model = new Subscriptions::BulkWithFilters { - Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + BulkWithFiltersConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }, + Cadence = Subscriptions::Cadence.Annual, ItemID = "item_id", Name = "Annual fee", }; @@ -9085,16 +6775,18 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::CumulativeGroupedAllocation + var model = new Subscriptions::BulkWithFilters { - Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + BulkWithFiltersConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }, + Cadence = Subscriptions::Cadence.Annual, ItemID = "item_id", Name = "Annual fee", @@ -9144,16 +6836,18 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::CumulativeGroupedAllocation + var model = new Subscriptions::BulkWithFilters { - Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + BulkWithFiltersConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }, + Cadence = Subscriptions::Cadence.Annual, ItemID = "item_id", Name = "Annual fee", @@ -9176,111 +6870,212 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class CumulativeGroupedAllocationCadenceTest : TestBase +public class BulkWithFiltersConfigTest : TestBase { - [Theory] - [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Annual)] - [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Monthly)] - [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.OneTime)] - [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Custom)] - public void Validation_Works(Subscriptions::CumulativeGroupedAllocationCadence rawValue) + [Fact] + public void FieldRoundtrip_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); + var model = new Subscriptions::BulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + List expectedFilters = + [ + new() { PropertyKey = "x", PropertyValue = "x" }, + ]; + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedFilters.Count, model.Filters.Count); + for (int i = 0; i < expectedFilters.Count; i++) + { + Assert.Equal(expectedFilters[i], model.Filters[i]); + } + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } } [Fact] - public void InvalidEnumValidationThrows_Works() + public void SerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + var model = new Subscriptions::BulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } - [Theory] - [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Annual)] - [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Monthly)] - [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.OneTime)] - [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Custom)] - public void SerializationRoundtrip_Works( - Subscriptions::CumulativeGroupedAllocationCadence rawValue - ) + [Fact] + public void FieldRoundtripThroughSerialization_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + var model = new Subscriptions::BulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); - Assert.Equal(value, deserialized); + List expectedFilters = + [ + new() { PropertyKey = "x", PropertyValue = "x" }, + ]; + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedFilters.Count, deserialized.Filters.Count); + for (int i = 0; i < expectedFilters.Count; i++) + { + Assert.Equal(expectedFilters[i], deserialized.Filters[i]); + } + Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + } } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void Validation_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + var model = new Subscriptions::BulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + model.Validate(); + } +} + +public class FilterTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::Filter { PropertyKey = "x", PropertyValue = "x" }; + + string expectedPropertyKey = "x"; + string expectedPropertyValue = "x"; + + Assert.Equal(expectedPropertyKey, model.PropertyKey); + Assert.Equal(expectedPropertyValue, model.PropertyValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Subscriptions::Filter { PropertyKey = "x", PropertyValue = "x" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Subscriptions::Filter { PropertyKey = "x", PropertyValue = "x" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPropertyKey = "x"; + string expectedPropertyValue = "x"; + + Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); + Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); + } + + [Fact] + public void Validation_Works() + { + var model = new Subscriptions::Filter { PropertyKey = "x", PropertyValue = "x" }; - Assert.Equal(value, deserialized); + model.Validate(); } } -public class CumulativeGroupedAllocationConfigTest : TestBase +public class TierTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::CumulativeGroupedAllocationConfig + var model = new Subscriptions::Tier { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; string expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); - Assert.Equal(expectedGroupingKey, model.GroupingKey); Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::CumulativeGroupedAllocationConfig + var model = new Subscriptions::Tier { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -9288,142 +7083,239 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::CumulativeGroupedAllocationConfig + var model = new Subscriptions::Tier { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; string expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; - Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); } [Fact] public void Validation_Works() { - var model = new Subscriptions::CumulativeGroupedAllocationConfig + var model = new Subscriptions::Tier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Subscriptions::Tier { UnitAmount = "unit_amount" }; + + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Subscriptions::Tier { UnitAmount = "unit_amount" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Subscriptions::Tier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, + }; + + Assert.Null(model.TierLowerBound); + Assert.True(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new Subscriptions::Tier { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", UnitAmount = "unit_amount", + + TierLowerBound = null, }; model.Validate(); } } -public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase +public class CadenceTest : TestBase +{ + [Theory] + [InlineData(Subscriptions::Cadence.Annual)] + [InlineData(Subscriptions::Cadence.SemiAnnual)] + [InlineData(Subscriptions::Cadence.Monthly)] + [InlineData(Subscriptions::Cadence.Quarterly)] + [InlineData(Subscriptions::Cadence.OneTime)] + [InlineData(Subscriptions::Cadence.Custom)] + public void Validation_Works(Subscriptions::Cadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Subscriptions::Cadence.Annual)] + [InlineData(Subscriptions::Cadence.SemiAnnual)] + [InlineData(Subscriptions::Cadence.Monthly)] + [InlineData(Subscriptions::Cadence.Quarterly)] + [InlineData(Subscriptions::Cadence.OneTime)] + [InlineData(Subscriptions::Cadence.Custom)] + public void SerializationRoundtrip_Works(Subscriptions::Cadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class ConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::CumulativeGroupedAllocationConversionRateConfig value = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + Subscriptions::ConversionRateConfig value = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; value.Validate(); } [Fact] public void TieredValidationWorks() { - Subscriptions::CumulativeGroupedAllocationConversionRateConfig value = - new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + Subscriptions::ConversionRateConfig value = new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; value.Validate(); } [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::CumulativeGroupedAllocationConversionRateConfig value = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + Subscriptions::ConversionRateConfig value = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); - } - - [Fact] - public void TieredSerializationRoundtripWorks() - { - Subscriptions::CumulativeGroupedAllocationConversionRateConfig value = - new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + } + + [Fact] + public void TieredSerializationRoundtripWorks() + { + Subscriptions::ConversionRateConfig value = new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class MinimumTest : TestBase +public class TieredWithProrationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::TieredWithProration { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::TieredWithProrationCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9456,16 +7348,14 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - Subscriptions::MinimumCadence.Annual; + ApiEnum expectedCadence = + Subscriptions::TieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - Subscriptions::MinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; + Subscriptions::TieredWithProrationConfig expectedTieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -9474,7 +7364,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::MinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::TieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9500,9 +7390,9 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedCadence, model.Cadence); Assert.Equal(expectedItemID, model.ItemID); - Assert.Equal(expectedMinimumConfig, model.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -9528,12 +7418,14 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::TieredWithProration { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::TieredWithProrationCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9567,7 +7459,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -9578,12 +7470,14 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::TieredWithProration { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::TieredWithProrationCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9617,22 +7511,20 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = - Subscriptions::MinimumCadence.Annual; + ApiEnum expectedCadence = + Subscriptions::TieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - Subscriptions::MinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; + Subscriptions::TieredWithProrationConfig expectedTieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -9641,7 +7533,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::MinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::TieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9667,9 +7559,9 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedCadence, deserialized.Cadence); Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.Equal(expectedMinimumConfig, deserialized.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -9698,12 +7590,14 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::TieredWithProration { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::TieredWithProrationCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9742,12 +7636,14 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::TieredWithProration { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::TieredWithProrationCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; Assert.Null(model.BillableMetricID); @@ -9781,12 +7677,14 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::TieredWithProration { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::TieredWithProrationCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; model.Validate(); @@ -9795,12 +7693,14 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::TieredWithProration { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::TieredWithProrationCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -9848,12 +7748,14 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::TieredWithProration { - Cadence = Subscriptions::MinimumCadence.Annual, + Cadence = Subscriptions::TieredWithProrationCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -9874,49 +7776,48 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class MinimumCadenceTest : TestBase +public class TieredWithProrationCadenceTest : TestBase { [Theory] - [InlineData(Subscriptions::MinimumCadence.Annual)] - [InlineData(Subscriptions::MinimumCadence.SemiAnnual)] - [InlineData(Subscriptions::MinimumCadence.Monthly)] - [InlineData(Subscriptions::MinimumCadence.Quarterly)] - [InlineData(Subscriptions::MinimumCadence.OneTime)] - [InlineData(Subscriptions::MinimumCadence.Custom)] - public void Validation_Works(Subscriptions::MinimumCadence rawValue) + [InlineData(Subscriptions::TieredWithProrationCadence.Annual)] + [InlineData(Subscriptions::TieredWithProrationCadence.SemiAnnual)] + [InlineData(Subscriptions::TieredWithProrationCadence.Monthly)] + [InlineData(Subscriptions::TieredWithProrationCadence.Quarterly)] + [InlineData(Subscriptions::TieredWithProrationCadence.OneTime)] + [InlineData(Subscriptions::TieredWithProrationCadence.Custom)] + public void Validation_Works(Subscriptions::TieredWithProrationCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); Assert.Throws(() => value.Validate()); } [Theory] - [InlineData(Subscriptions::MinimumCadence.Annual)] - [InlineData(Subscriptions::MinimumCadence.SemiAnnual)] - [InlineData(Subscriptions::MinimumCadence.Monthly)] - [InlineData(Subscriptions::MinimumCadence.Quarterly)] - [InlineData(Subscriptions::MinimumCadence.OneTime)] - [InlineData(Subscriptions::MinimumCadence.Custom)] - public void SerializationRoundtrip_Works(Subscriptions::MinimumCadence rawValue) + [InlineData(Subscriptions::TieredWithProrationCadence.Annual)] + [InlineData(Subscriptions::TieredWithProrationCadence.SemiAnnual)] + [InlineData(Subscriptions::TieredWithProrationCadence.Monthly)] + [InlineData(Subscriptions::TieredWithProrationCadence.Quarterly)] + [InlineData(Subscriptions::TieredWithProrationCadence.OneTime)] + [InlineData(Subscriptions::TieredWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works(Subscriptions::TieredWithProrationCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -9925,48 +7826,50 @@ public void SerializationRoundtrip_Works(Subscriptions::MinimumCadence rawValue) [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class MinimumConfigTest : TestBase +public class TieredWithProrationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::MinimumConfig + var model = new Subscriptions::TieredWithProrationConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } } [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::MinimumConfig + var model = new Subscriptions::TieredWithProrationConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -9977,131 +7880,164 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::MinimumConfig + var model = new Subscriptions::TieredWithProrationConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + } } [Fact] public void Validation_Works() { - var model = new Subscriptions::MinimumConfig + var model = new Subscriptions::TieredWithProrationConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; model.Validate(); } +} +public class TieredWithProrationConfigTierTest : TestBase +{ [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + public void FieldRoundtrip_Works() { - var model = new Subscriptions::MinimumConfig { MinimumAmount = "minimum_amount" }; + var model = new Subscriptions::TieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() + public void SerializationRoundtrip_Works() { - var model = new Subscriptions::MinimumConfig { MinimumAmount = "minimum_amount" }; + var model = new Subscriptions::TieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; - model.Validate(); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::MinimumConfig + var model = new Subscriptions::TieredWithProrationConfigTier { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() + public void Validation_Works() { - var model = new Subscriptions::MinimumConfig + var model = new Subscriptions::TieredWithProrationConfigTier { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; model.Validate(); } } -public class MinimumConversionRateConfigTest : TestBase +public class TieredWithProrationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::MinimumConversionRateConfig value = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + Subscriptions::TieredWithProrationConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; value.Validate(); } [Fact] public void TieredValidationWorks() { - Subscriptions::MinimumConversionRateConfig value = new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + Subscriptions::TieredWithProrationConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; value.Validate(); } [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::MinimumConversionRateConfig value = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + Subscriptions::TieredWithProrationConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -10109,41 +8045,49 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::MinimumConversionRateConfig value = new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + Subscriptions::TieredWithProrationConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class PercentTest : TestBase +public class GroupedWithMinMaxThresholdsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::GroupedWithMinMaxThresholds { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -10176,12 +8120,21 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - Subscriptions::PercentCadence.Annual; + ApiEnum expectedCadence = + Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual; + Subscriptions::GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); string expectedName = "Annual fee"; - Subscriptions::PercentConfig expectedPercentConfig = new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -10190,7 +8143,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::PercentConversionRateConfig expectedConversionRateConfig = + Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10215,10 +8168,13 @@ public void FieldRoundtrip_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal( + expectedGroupedWithMinMaxThresholdsConfig, + model.GroupedWithMinMaxThresholdsConfig + ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedPercentConfig, model.PercentConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -10244,12 +8200,18 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::GroupedWithMinMaxThresholds { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -10283,7 +8245,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10294,12 +8256,18 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::GroupedWithMinMaxThresholds { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -10333,18 +8301,27 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = - Subscriptions::PercentCadence.Annual; + ApiEnum expectedCadence = + Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual; + Subscriptions::GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); string expectedName = "Annual fee"; - Subscriptions::PercentConfig expectedPercentConfig = new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -10353,7 +8330,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::PercentConversionRateConfig expectedConversionRateConfig = + Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10378,10 +8355,13 @@ public void FieldRoundtripThroughSerialization_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal( + expectedGroupedWithMinMaxThresholdsConfig, + deserialized.GroupedWithMinMaxThresholdsConfig + ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedPercentConfig, deserialized.PercentConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -10410,12 +8390,18 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::GroupedWithMinMaxThresholds { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -10454,12 +8440,18 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::GroupedWithMinMaxThresholds { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), }; Assert.Null(model.BillableMetricID); @@ -10493,12 +8485,18 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::GroupedWithMinMaxThresholds { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), }; model.Validate(); @@ -10507,12 +8505,18 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::GroupedWithMinMaxThresholds { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -10560,12 +8564,18 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::GroupedWithMinMaxThresholds { - Cadence = Subscriptions::PercentCadence.Annual, + Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -10586,49 +8596,50 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class PercentCadenceTest : TestBase +public class GroupedWithMinMaxThresholdsCadenceTest : TestBase { [Theory] - [InlineData(Subscriptions::PercentCadence.Annual)] - [InlineData(Subscriptions::PercentCadence.SemiAnnual)] - [InlineData(Subscriptions::PercentCadence.Monthly)] - [InlineData(Subscriptions::PercentCadence.Quarterly)] - [InlineData(Subscriptions::PercentCadence.OneTime)] - [InlineData(Subscriptions::PercentCadence.Custom)] - public void Validation_Works(Subscriptions::PercentCadence rawValue) + [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Custom)] + public void Validation_Works(Subscriptions::GroupedWithMinMaxThresholdsCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); Assert.Throws(() => value.Validate()); } [Theory] - [InlineData(Subscriptions::PercentCadence.Annual)] - [InlineData(Subscriptions::PercentCadence.SemiAnnual)] - [InlineData(Subscriptions::PercentCadence.Monthly)] - [InlineData(Subscriptions::PercentCadence.Quarterly)] - [InlineData(Subscriptions::PercentCadence.OneTime)] - [InlineData(Subscriptions::PercentCadence.Custom)] - public void SerializationRoundtrip_Works(Subscriptions::PercentCadence rawValue) + [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(Subscriptions::GroupedWithMinMaxThresholdsCadence.Custom)] + public void SerializationRoundtrip_Works( + Subscriptions::GroupedWithMinMaxThresholdsCadence rawValue + ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -10637,41 +8648,59 @@ public void SerializationRoundtrip_Works(Subscriptions::PercentCadence rawValue) [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class PercentConfigTest : TestBase +public class GroupedWithMinMaxThresholdsConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::PercentConfig { Percent = 0 }; + var model = new Subscriptions::GroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; - double expectedPercent = 0; + string expectedGroupingKey = "x"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedPercent, model.Percent); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedMaximumCharge, model.MaximumCharge); + Assert.Equal(expectedMinimumCharge, model.MinimumCharge); + Assert.Equal(expectedPerUnitRate, model.PerUnitRate); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::PercentConfig { Percent = 0 }; + var model = new Subscriptions::GroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -10679,75 +8708,98 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::PercentConfig { Percent = 0 }; + var model = new Subscriptions::GroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); - double expectedPercent = 0; + string expectedGroupingKey = "x"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedPercent, deserialized.Percent); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); + Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); + Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); } [Fact] public void Validation_Works() { - var model = new Subscriptions::PercentConfig { Percent = 0 }; + var model = new Subscriptions::GroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; model.Validate(); } } -public class PercentConversionRateConfigTest : TestBase +public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::PercentConversionRateConfig value = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; value.Validate(); } [Fact] public void TieredValidationWorks() { - Subscriptions::PercentConversionRateConfig value = new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; value.Validate(); } [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::PercentConversionRateConfig value = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -10755,43 +8807,46 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::PercentConversionRateConfig value = new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class EventOutputTest : TestBase +public class CumulativeGroupedAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::CumulativeGroupedAllocation { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, ItemID = "item_id", Name = "Annual fee", @@ -10827,16 +8882,20 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - Subscriptions::EventOutputCadence.Annual; - Subscriptions::EventOutputConfig expectedEventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + ApiEnum expectedCadence = + Subscriptions::CumulativeGroupedAllocationCadence.Annual; + Subscriptions::CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -10846,7 +8905,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::EventOutputConversionRateConfig expectedConversionRateConfig = + Subscriptions::CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10871,7 +8930,10 @@ public void FieldRoundtrip_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedEventOutputConfig, model.EventOutputConfig); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + model.CumulativeGroupedAllocationConfig + ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); @@ -10900,14 +8962,15 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::CumulativeGroupedAllocation { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, ItemID = "item_id", Name = "Annual fee", @@ -10944,7 +9007,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10955,14 +9018,15 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::CumulativeGroupedAllocation { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, ItemID = "item_id", Name = "Annual fee", @@ -10999,22 +9063,26 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = - Subscriptions::EventOutputCadence.Annual; - Subscriptions::EventOutputConfig expectedEventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + ApiEnum expectedCadence = + Subscriptions::CumulativeGroupedAllocationCadence.Annual; + Subscriptions::CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -11024,7 +9092,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::EventOutputConversionRateConfig expectedConversionRateConfig = + Subscriptions::CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -11049,7 +9117,10 @@ public void FieldRoundtripThroughSerialization_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedEventOutputConfig, deserialized.EventOutputConfig); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + deserialized.CumulativeGroupedAllocationConfig + ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); @@ -11081,14 +9152,15 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::CumulativeGroupedAllocation { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, ItemID = "item_id", Name = "Annual fee", @@ -11130,14 +9202,15 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::CumulativeGroupedAllocation { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, ItemID = "item_id", Name = "Annual fee", @@ -11174,14 +9247,15 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::CumulativeGroupedAllocation { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, ItemID = "item_id", Name = "Annual fee", @@ -11193,14 +9267,15 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::CumulativeGroupedAllocation { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, ItemID = "item_id", Name = "Annual fee", @@ -11251,14 +9326,15 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::CumulativeGroupedAllocation { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, ItemID = "item_id", Name = "Annual fee", @@ -11282,49 +9358,50 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class EventOutputCadenceTest : TestBase +public class CumulativeGroupedAllocationCadenceTest : TestBase { [Theory] - [InlineData(Subscriptions::EventOutputCadence.Annual)] - [InlineData(Subscriptions::EventOutputCadence.SemiAnnual)] - [InlineData(Subscriptions::EventOutputCadence.Monthly)] - [InlineData(Subscriptions::EventOutputCadence.Quarterly)] - [InlineData(Subscriptions::EventOutputCadence.OneTime)] - [InlineData(Subscriptions::EventOutputCadence.Custom)] - public void Validation_Works(Subscriptions::EventOutputCadence rawValue) + [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Annual)] + [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Monthly)] + [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.OneTime)] + [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Custom)] + public void Validation_Works(Subscriptions::CumulativeGroupedAllocationCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); Assert.Throws(() => value.Validate()); } [Theory] - [InlineData(Subscriptions::EventOutputCadence.Annual)] - [InlineData(Subscriptions::EventOutputCadence.SemiAnnual)] - [InlineData(Subscriptions::EventOutputCadence.Monthly)] - [InlineData(Subscriptions::EventOutputCadence.Quarterly)] - [InlineData(Subscriptions::EventOutputCadence.OneTime)] - [InlineData(Subscriptions::EventOutputCadence.Custom)] - public void SerializationRoundtrip_Works(Subscriptions::EventOutputCadence rawValue) + [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Annual)] + [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Monthly)] + [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.OneTime)] + [InlineData(Subscriptions::CumulativeGroupedAllocationCadence.Custom)] + public void SerializationRoundtrip_Works( + Subscriptions::CumulativeGroupedAllocationCadence rawValue + ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -11333,55 +9410,59 @@ public void SerializationRoundtrip_Works(Subscriptions::EventOutputCadence rawVa [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class EventOutputConfigTest : TestBase +public class CumulativeGroupedAllocationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::EventOutputConfig + var model = new Subscriptions::CumulativeGroupedAllocationConfig { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; - string expectedUnitRatingKey = "x"; - string expectedDefaultUnitRate = "default_unit_rate"; - string expectedGroupingKey = "grouping_key"; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedUnitRatingKey, model.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, model.DefaultUnitRate); + Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, model.GroupAllocation); Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::EventOutputConfig + var model = new Subscriptions::CumulativeGroupedAllocationConfig { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -11389,110 +9470,66 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::EventOutputConfig + var model = new Subscriptions::CumulativeGroupedAllocationConfig { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); - string expectedUnitRatingKey = "x"; - string expectedDefaultUnitRate = "default_unit_rate"; - string expectedGroupingKey = "grouping_key"; - - Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - } - - [Fact] - public void Validation_Works() - { - var model = new Subscriptions::EventOutputConfig - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new Subscriptions::EventOutputConfig { UnitRatingKey = "x" }; - - Assert.Null(model.DefaultUnitRate); - Assert.False(model.RawData.ContainsKey("default_unit_rate")); - Assert.Null(model.GroupingKey); - Assert.False(model.RawData.ContainsKey("grouping_key")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::EventOutputConfig { UnitRatingKey = "x" }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new Subscriptions::EventOutputConfig - { - UnitRatingKey = "x", - - DefaultUnitRate = null, - GroupingKey = null, - }; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; - Assert.Null(model.DefaultUnitRate); - Assert.True(model.RawData.ContainsKey("default_unit_rate")); - Assert.Null(model.GroupingKey); - Assert.True(model.RawData.ContainsKey("grouping_key")); + Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void Validation_Works() { - var model = new Subscriptions::EventOutputConfig + var model = new Subscriptions::CumulativeGroupedAllocationConfig { - UnitRatingKey = "x", - - DefaultUnitRate = null, - GroupingKey = null, + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; model.Validate(); } } -public class EventOutputConversionRateConfigTest : TestBase +public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::EventOutputConversionRateConfig value = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + Subscriptions::CumulativeGroupedAllocationConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; value.Validate(); } [Fact] public void TieredValidationWorks() { - Subscriptions::EventOutputConversionRateConfig value = + Subscriptions::CumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -11513,14 +9550,15 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::EventOutputConversionRateConfig value = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + Subscriptions::CumulativeGroupedAllocationConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -11531,7 +9569,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::EventOutputConversionRateConfig value = + Subscriptions::CumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -11548,7 +9586,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -11557,145 +9595,157 @@ public void TieredSerializationRoundtripWorks() } } -public class ExternalMarketplaceTest : TestBase -{ - [Theory] - [InlineData(Subscriptions::ExternalMarketplace.Google)] - [InlineData(Subscriptions::ExternalMarketplace.Aws)] - [InlineData(Subscriptions::ExternalMarketplace.Azure)] - public void Validation_Works(Subscriptions::ExternalMarketplace rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(Subscriptions::ExternalMarketplace.Google)] - [InlineData(Subscriptions::ExternalMarketplace.Aws)] - [InlineData(Subscriptions::ExternalMarketplace.Azure)] - public void SerializationRoundtrip_Works(Subscriptions::ExternalMarketplace rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } -} - -public class RemoveAdjustmentTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; - - string expectedAdjustmentID = "h74gfhdjvn7ujokd"; - - Assert.Equal(expectedAdjustmentID, model.AdjustmentID); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedAdjustmentID = "h74gfhdjvn7ujokd"; - - Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); - } - - [Fact] - public void Validation_Works() - { - var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; - - model.Validate(); - } -} - -public class RemovePriceTest : TestBase +public class PercentTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::RemovePrice + var model = new Subscriptions::Percent { + Cadence = Subscriptions::PercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, ExternalPriceID = "external_price_id", - PriceID = "h74gfhdjvn7ujokd", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; + ApiEnum expectedCadence = + Subscriptions::PercentCadence.Annual; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + string expectedName = "Annual fee"; + Subscriptions::PercentConfig expectedPercentConfig = new(0); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::PercentConversionRateConfig expectedConversionRateConfig = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; string expectedExternalPriceID = "external_price_id"; - string expectedPriceID = "h74gfhdjvn7ujokd"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedItemID, model.ItemID); + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedPercentConfig, model.PercentConfig); + Assert.Equal(expectedBillableMetricID, model.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, model.ConversionRate); + Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedPriceID, model.PriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, model.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, model.ReferenceID); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::RemovePrice + var model = new Subscriptions::Percent { + Cadence = Subscriptions::PercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, ExternalPriceID = "external_price_id", - PriceID = "h74gfhdjvn7ujokd", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -11706,518 +9756,457 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::RemovePrice + var model = new Subscriptions::Percent { + Cadence = Subscriptions::PercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, ExternalPriceID = "external_price_id", - PriceID = "h74gfhdjvn7ujokd", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); + ApiEnum expectedCadence = + Subscriptions::PercentCadence.Annual; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + string expectedName = "Annual fee"; + Subscriptions::PercentConfig expectedPercentConfig = new(0); + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::PercentConversionRateConfig expectedConversionRateConfig = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; string expectedExternalPriceID = "external_price_id"; - string expectedPriceID = "h74gfhdjvn7ujokd"; - - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedPriceID, deserialized.PriceID); - } - - [Fact] - public void Validation_Works() - { - var model = new Subscriptions::RemovePrice + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { - ExternalPriceID = "external_price_id", - PriceID = "h74gfhdjvn7ujokd", + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new Subscriptions::RemovePrice { }; - - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.PriceID); - Assert.False(model.RawData.ContainsKey("price_id")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::RemovePrice { }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new Subscriptions::RemovePrice { ExternalPriceID = null, PriceID = null }; - - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.PriceID); - Assert.True(model.RawData.ContainsKey("price_id")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new Subscriptions::RemovePrice { ExternalPriceID = null, PriceID = null }; + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedPercentConfig, deserialized.PercentConfig); + Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, deserialized.ConversionRate); + Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); - model.Validate(); + Assert.Equal(value, deserialized.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); } -} -public class ReplaceAdjustmentTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void Validation_Works() { - var model = new Subscriptions::ReplaceAdjustment + var model = new Subscriptions::Percent { - Adjustment = new NewPercentageDiscount() + Cadence = Subscriptions::PercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }, - ReplacesAdjustmentID = "replaces_adjustment_id", - }; - - Subscriptions::ReplaceAdjustmentAdjustment expectedAdjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; - Assert.Equal(expectedAdjustment, model.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); + model.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::ReplaceAdjustment + var model = new Subscriptions::Percent { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - ReplacesAdjustmentID = "replaces_adjustment_id", + Cadence = Subscriptions::PercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), }; - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.False(model.RawData.ContainsKey("reference_id")); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::ReplaceAdjustment + var model = new Subscriptions::Percent { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - ReplacesAdjustmentID = "replaces_adjustment_id", + Cadence = Subscriptions::PercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), }; - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + model.Validate(); + } - Subscriptions::ReplaceAdjustmentAdjustment expectedAdjustment = new NewPercentageDiscount() + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Subscriptions::Percent { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, + Cadence = Subscriptions::PercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + Metadata = null, + ReferenceID = null, }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; - Assert.Equal(expectedAdjustment, deserialized.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.True(model.RawData.ContainsKey("reference_id")); } [Fact] - public void Validation_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::ReplaceAdjustment + var model = new Subscriptions::Percent { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - ReplacesAdjustmentID = "replaces_adjustment_id", + Cadence = Subscriptions::PercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + Metadata = null, + ReferenceID = null, }; model.Validate(); } } -public class ReplaceAdjustmentAdjustmentTest : TestBase +public class PercentCadenceTest : TestBase { - [Fact] - public void NewPercentageDiscountValidationWorks() + [Theory] + [InlineData(Subscriptions::PercentCadence.Annual)] + [InlineData(Subscriptions::PercentCadence.SemiAnnual)] + [InlineData(Subscriptions::PercentCadence.Monthly)] + [InlineData(Subscriptions::PercentCadence.Quarterly)] + [InlineData(Subscriptions::PercentCadence.OneTime)] + [InlineData(Subscriptions::PercentCadence.Custom)] + public void Validation_Works(Subscriptions::PercentCadence rawValue) { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }; + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; value.Validate(); } [Fact] - public void NewUsageDiscountValidationWorks() + public void InvalidEnumValidationThrows_Works() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewUsageDiscount() - { - AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewUsageDiscountFilterField.PriceID, - Operator = NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewUsageDiscountPriceType.Usage, - }; - value.Validate(); + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); } - [Fact] - public void NewAmountDiscountValidationWorks() + [Theory] + [InlineData(Subscriptions::PercentCadence.Annual)] + [InlineData(Subscriptions::PercentCadence.SemiAnnual)] + [InlineData(Subscriptions::PercentCadence.Monthly)] + [InlineData(Subscriptions::PercentCadence.Quarterly)] + [InlineData(Subscriptions::PercentCadence.OneTime)] + [InlineData(Subscriptions::PercentCadence.Custom)] + public void SerializationRoundtrip_Works(Subscriptions::PercentCadence rawValue) { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewAmountDiscount() - { - AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewAmountDiscountFilterField.PriceID, - Operator = NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = PriceType.Usage, - }; - value.Validate(); + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); } [Fact] - public void NewMinimumValidationWorks() + public void InvalidEnumSerializationRoundtrip_Works() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewMinimum() - { - AdjustmentType = NewMinimumAdjustmentType.Minimum, - ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMinimumFilterField.PriceID, - Operator = NewMinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMinimumPriceType.Usage, - }; - value.Validate(); + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); } +} +public class PercentConfigTest : TestBase +{ [Fact] - public void NewMaximumValidationWorks() + public void FieldRoundtrip_Works() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewMaximum() - { - AdjustmentType = NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMaximumFilterField.PriceID, - Operator = NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMaximumPriceType.Usage, - }; - value.Validate(); + var model = new Subscriptions::PercentConfig { Percent = 0 }; + + double expectedPercent = 0; + + Assert.Equal(expectedPercent, model.Percent); } [Fact] - public void NewPercentageDiscountSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, + var model = new Subscriptions::PercentConfig { Percent = 0 }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, ModelBase.SerializerOptions ); - Assert.Equal(value, deserialized); + Assert.Equal(model, deserialized); } [Fact] - public void NewUsageDiscountSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewUsageDiscount() - { - AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewUsageDiscountFilterField.PriceID, - Operator = NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewUsageDiscountPriceType.Usage, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var model = new Subscriptions::PercentConfig { Percent = 0 }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); + Assert.NotNull(deserialized); - Assert.Equal(value, deserialized); + double expectedPercent = 0; + + Assert.Equal(expectedPercent, deserialized.Percent); } [Fact] - public void NewAmountDiscountSerializationRoundtripWorks() + public void Validation_Works() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewAmountDiscount() + var model = new Subscriptions::PercentConfig { Percent = 0 }; + + model.Validate(); + } +} + +public class PercentConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + Subscriptions::PercentConversionRateConfig value = new SharedUnitConversionRateConfig() { - AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewAmountDiscountFilterField.PriceID, - Operator = NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = PriceType.Usage, + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + value.Validate(); + } - Assert.Equal(value, deserialized); + [Fact] + public void TieredValidationWorks() + { + Subscriptions::PercentConversionRateConfig value = new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); } [Fact] - public void NewMinimumSerializationRoundtripWorks() + public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewMinimum() + Subscriptions::PercentConversionRateConfig value = new SharedUnitConversionRateConfig() { - AdjustmentType = NewMinimumAdjustmentType.Minimum, - ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMinimumFilterField.PriceID, - Operator = NewMinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMinimumPriceType.Usage, + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -12226,30 +10215,24 @@ public void NewMinimumSerializationRoundtripWorks() } [Fact] - public void NewMaximumSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewMaximum() + Subscriptions::PercentConversionRateConfig value = new SharedTieredConversionRateConfig() { - AdjustmentType = NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMaximumFilterField.PriceID, - Operator = NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMaximumPriceType.Usage, + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -12258,273 +10241,172 @@ public void NewMaximumSerializationRoundtripWorks() } } -public class ReplacePriceTest : TestBase +public class EventOutputTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::ReplacePrice + var model = new Subscriptions::EventOutput { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Cadence = Subscriptions::EventOutputCadence.Annual, + EventOutputConfig = new() { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }, - Discounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ], - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 2, - MaximumAmount = "1.23", - MinimumAmount = "1.23", - Price = new Subscriptions::NewSubscriptionUnitPrice() + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, - PriceID = "h74gfhdjvn7ujokd", - }; - - string expectedReplacesPriceID = "replaces_price_id"; - NewAllocationPrice expectedAllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }; - List expectedDiscounts = - [ - new() + Currency = "currency", + DimensionalPriceConfiguration = new() { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", }, - ]; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 2; - string expectedMaximumAmount = "1.23"; - string expectedMinimumAmount = "1.23"; - Subscriptions::ReplacePricePrice expectedPrice = - new Subscriptions::NewSubscriptionUnitPrice() + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ApiEnum expectedCadence = + Subscriptions::EventOutputCadence.Annual; + Subscriptions::EventOutputConfig expectedEventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::EventOutputConversionRateConfig expectedConversionRateConfig = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; - string expectedPriceID = "h74gfhdjvn7ujokd"; - - Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); - Assert.Equal(expectedAllocationPrice, model.AllocationPrice); - Assert.NotNull(model.Discounts); - Assert.Equal(expectedDiscounts.Count, model.Discounts.Count); - for (int i = 0; i < expectedDiscounts.Count; i++) + string expectedCurrency = "currency"; + NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { - Assert.Equal(expectedDiscounts[i], model.Discounts[i]); - } + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedEventOutputConfig, model.EventOutputConfig); + Assert.Equal(expectedItemID, model.ItemID); + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedBillableMetricID, model.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, model.ConversionRate); + Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedMaximumAmount, model.MaximumAmount); - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedPrice, model.Price); - Assert.Equal(expectedPriceID, model.PriceID); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, model.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, model.ReferenceID); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::ReplacePrice + var model = new Subscriptions::EventOutput { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Cadence = Subscriptions::EventOutputCadence.Annual, + EventOutputConfig = new() { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", }, - Discounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ], ExternalPriceID = "external_price_id", - FixedPriceQuantity = 2, - MaximumAmount = "1.23", - MinimumAmount = "1.23", - Price = new Subscriptions::NewSubscriptionUnitPrice() + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, - PriceID = "h74gfhdjvn7ujokd", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -12535,271 +10417,173 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::ReplacePrice + var model = new Subscriptions::EventOutput { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ], - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 2, - MaximumAmount = "1.23", - MinimumAmount = "1.23", - Price = new Subscriptions::NewSubscriptionUnitPrice() + Cadence = Subscriptions::EventOutputCadence.Annual, + EventOutputConfig = new() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }, - PriceID = "h74gfhdjvn7ujokd", + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedReplacesPriceID = "replaces_price_id"; - NewAllocationPrice expectedAllocationPrice = new() + ApiEnum expectedCadence = + Subscriptions::EventOutputCadence.Annual; + Subscriptions::EventOutputConfig expectedEventOutputConfig = new() { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - List expectedDiscounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ]; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 2; - string expectedMaximumAmount = "1.23"; - string expectedMinimumAmount = "1.23"; - Subscriptions::ReplacePricePrice expectedPrice = - new Subscriptions::NewSubscriptionUnitPrice() + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::EventOutputConversionRateConfig expectedConversionRateConfig = + new SharedUnitConversionRateConfig() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; - string expectedPriceID = "h74gfhdjvn7ujokd"; - - Assert.Equal(expectedReplacesPriceID, deserialized.ReplacesPriceID); - Assert.Equal(expectedAllocationPrice, deserialized.AllocationPrice); - Assert.NotNull(deserialized.Discounts); - Assert.Equal(expectedDiscounts.Count, deserialized.Discounts.Count); - for (int i = 0; i < expectedDiscounts.Count; i++) + string expectedCurrency = "currency"; + NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() { - Assert.Equal(expectedDiscounts[i], deserialized.Discounts[i]); - } + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; + + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedEventOutputConfig, deserialized.EventOutputConfig); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, deserialized.ConversionRate); + Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedMaximumAmount, deserialized.MaximumAmount); - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedPrice, deserialized.Price); - Assert.Equal(expectedPriceID, deserialized.PriceID); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, deserialized.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); } [Fact] public void Validation_Works() { - var model = new Subscriptions::ReplacePrice + var model = new Subscriptions::EventOutput { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Cadence = Subscriptions::EventOutputCadence.Annual, + EventOutputConfig = new() { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", }, - Discounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ], ExternalPriceID = "external_price_id", - FixedPriceQuantity = 2, - MaximumAmount = "1.23", - MinimumAmount = "1.23", - Price = new Subscriptions::NewSubscriptionUnitPrice() + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, - PriceID = "h74gfhdjvn7ujokd", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; model.Validate(); @@ -12808,30 +10592,62 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::ReplacePrice { ReplacesPriceID = "replaces_price_id" }; + var model = new Subscriptions::EventOutput + { + Cadence = Subscriptions::EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + }; - Assert.Null(model.AllocationPrice); - Assert.False(model.RawData.ContainsKey("allocation_price")); - Assert.Null(model.Discounts); - Assert.False(model.RawData.ContainsKey("discounts")); + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); Assert.Null(model.ExternalPriceID); Assert.False(model.RawData.ContainsKey("external_price_id")); Assert.Null(model.FixedPriceQuantity); Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.MaximumAmount); - Assert.False(model.RawData.ContainsKey("maximum_amount")); - Assert.Null(model.MinimumAmount); - Assert.False(model.RawData.ContainsKey("minimum_amount")); - Assert.Null(model.Price); - Assert.False(model.RawData.ContainsKey("price")); - Assert.Null(model.PriceID); - Assert.False(model.RawData.ContainsKey("price_id")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.False(model.RawData.ContainsKey("reference_id")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::ReplacePrice { ReplacesPriceID = "replaces_price_id" }; + var model = new Subscriptions::EventOutput + { + Cadence = Subscriptions::EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + }; model.Validate(); } @@ -12839,1286 +10655,1123 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::ReplacePrice + var model = new Subscriptions::EventOutput { - ReplacesPriceID = "replaces_price_id", + Cadence = Subscriptions::EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", - AllocationPrice = null, - Discounts = null, + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, ExternalPriceID = null, FixedPriceQuantity = null, - MaximumAmount = null, - MinimumAmount = null, - Price = null, - PriceID = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + Metadata = null, + ReferenceID = null, }; - Assert.Null(model.AllocationPrice); - Assert.True(model.RawData.ContainsKey("allocation_price")); - Assert.Null(model.Discounts); - Assert.True(model.RawData.ContainsKey("discounts")); + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); Assert.Null(model.ExternalPriceID); Assert.True(model.RawData.ContainsKey("external_price_id")); Assert.Null(model.FixedPriceQuantity); Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.MaximumAmount); - Assert.True(model.RawData.ContainsKey("maximum_amount")); - Assert.Null(model.MinimumAmount); - Assert.True(model.RawData.ContainsKey("minimum_amount")); - Assert.Null(model.Price); - Assert.True(model.RawData.ContainsKey("price")); - Assert.Null(model.PriceID); - Assert.True(model.RawData.ContainsKey("price_id")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.True(model.RawData.ContainsKey("reference_id")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::ReplacePrice + var model = new Subscriptions::EventOutput { - ReplacesPriceID = "replaces_price_id", + Cadence = Subscriptions::EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", - AllocationPrice = null, - Discounts = null, + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, ExternalPriceID = null, FixedPriceQuantity = null, - MaximumAmount = null, - MinimumAmount = null, - Price = null, - PriceID = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + Metadata = null, + ReferenceID = null, }; - model.Validate(); + model.Validate(); + } +} + +public class EventOutputCadenceTest : TestBase +{ + [Theory] + [InlineData(Subscriptions::EventOutputCadence.Annual)] + [InlineData(Subscriptions::EventOutputCadence.SemiAnnual)] + [InlineData(Subscriptions::EventOutputCadence.Monthly)] + [InlineData(Subscriptions::EventOutputCadence.Quarterly)] + [InlineData(Subscriptions::EventOutputCadence.OneTime)] + [InlineData(Subscriptions::EventOutputCadence.Custom)] + public void Validation_Works(Subscriptions::EventOutputCadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Subscriptions::EventOutputCadence.Annual)] + [InlineData(Subscriptions::EventOutputCadence.SemiAnnual)] + [InlineData(Subscriptions::EventOutputCadence.Monthly)] + [InlineData(Subscriptions::EventOutputCadence.Quarterly)] + [InlineData(Subscriptions::EventOutputCadence.OneTime)] + [InlineData(Subscriptions::EventOutputCadence.Custom)] + public void SerializationRoundtrip_Works(Subscriptions::EventOutputCadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); } } -public class ReplacePricePriceTest : TestBase +public class EventOutputConfigTest : TestBase { [Fact] - public void NewSubscriptionUnitValidationWorks() + public void FieldRoundtrip_Works() { - Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionUnitPrice() + var model = new Subscriptions::EventOutputConfig { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - value.Validate(); - } - [Fact] - public void NewSubscriptionTieredValidationWorks() - { - Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionTieredPrice() - { - Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, - Name = "Annual fee", - TieredConfig = new() - { - Tiers = - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ], - Prorated = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + string expectedUnitRatingKey = "x"; + string expectedDefaultUnitRate = "default_unit_rate"; + string expectedGroupingKey = "grouping_key"; + + Assert.Equal(expectedUnitRatingKey, model.UnitRatingKey); + Assert.Equal(expectedDefaultUnitRate, model.DefaultUnitRate); + Assert.Equal(expectedGroupingKey, model.GroupingKey); } [Fact] - public void NewSubscriptionBulkValidationWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionBulkPrice() + var model = new Subscriptions::EventOutputConfig { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::ModelType.Bulk, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - value.Validate(); - } - [Fact] - public void BulkWithFiltersValidationWorks() - { - Subscriptions::ReplacePricePrice value = - new Subscriptions::ReplacePricePriceBulkWithFilters() - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewSubscriptionPackageValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionPackagePrice() + var model = new Subscriptions::EventOutputConfig { - Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, - Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - value.Validate(); + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedUnitRatingKey = "x"; + string expectedDefaultUnitRate = "default_unit_rate"; + string expectedGroupingKey = "grouping_key"; + + Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); + Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); } [Fact] - public void NewSubscriptionMatrixValidationWorks() + public void Validation_Works() { - Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionMatrixPrice() + var model = new Subscriptions::EventOutputConfig { - Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, - ItemID = "item_id", - MatrixConfig = new() - { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], - }, - ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewSubscriptionThresholdTotalAmountValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() - { - Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, - Name = "Annual fee", - ThresholdTotalAmountConfig = new() - { - ConsumptionTable = - [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - ], - Prorate = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + var model = new Subscriptions::EventOutputConfig { UnitRatingKey = "x" }; + + Assert.Null(model.DefaultUnitRate); + Assert.False(model.RawData.ContainsKey("default_unit_rate")); + Assert.Null(model.GroupingKey); + Assert.False(model.RawData.ContainsKey("grouping_key")); } [Fact] - public void NewSubscriptionTieredPackageValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackagePrice() - { - Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, - Name = "Annual fee", - TieredPackageConfig = new() - { - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + var model = new Subscriptions::EventOutputConfig { UnitRatingKey = "x" }; + + model.Validate(); } [Fact] - public void NewSubscriptionTieredWithMinimumValidationWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredWithMinimumPrice() - { - Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, - Name = "Annual fee", - TieredWithMinimumConfig = new() - { - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - HideZeroAmountTiers = true, - Prorate = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + var model = new Subscriptions::EventOutputConfig + { + UnitRatingKey = "x", + + DefaultUnitRate = null, + GroupingKey = null, + }; + + Assert.Null(model.DefaultUnitRate); + Assert.True(model.RawData.ContainsKey("default_unit_rate")); + Assert.Null(model.GroupingKey); + Assert.True(model.RawData.ContainsKey("grouping_key")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new Subscriptions::EventOutputConfig + { + UnitRatingKey = "x", + + DefaultUnitRate = null, + GroupingKey = null, + }; + + model.Validate(); + } +} + +public class EventOutputConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + Subscriptions::EventOutputConversionRateConfig value = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; value.Validate(); } [Fact] - public void NewSubscriptionGroupedTieredValidationWorks() + public void TieredValidationWorks() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPrice() + Subscriptions::EventOutputConversionRateConfig value = + new SharedTieredConversionRateConfig() { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() - { - GroupingKey = "x", - Tiers = + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - }, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), }; value.Validate(); } [Fact] - public void NewSubscriptionTieredPackageWithMinimumValidationWorks() + public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + Subscriptions::EventOutputConversionRateConfig value = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void TieredSerializationRoundtripWorks() + { + Subscriptions::EventOutputConversionRateConfig value = + new SharedTieredConversionRateConfig() { - Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, - Name = "Annual fee", - TieredPackageWithMinimumConfig = new() - { - PackageSize = 0, - Tiers = + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( [ new() { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, }, - ], - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ] + ), }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class ExternalMarketplaceTest : TestBase +{ + [Theory] + [InlineData(Subscriptions::ExternalMarketplace.Google)] + [InlineData(Subscriptions::ExternalMarketplace.Aws)] + [InlineData(Subscriptions::ExternalMarketplace.Azure)] + public void Validation_Works(Subscriptions::ExternalMarketplace rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; value.Validate(); } [Fact] - public void NewSubscriptionPackageWithAllocationValidationWorks() + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Subscriptions::ExternalMarketplace.Google)] + [InlineData(Subscriptions::ExternalMarketplace.Aws)] + [InlineData(Subscriptions::ExternalMarketplace.Azure)] + public void SerializationRoundtrip_Works(Subscriptions::ExternalMarketplace rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class RemoveAdjustmentTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; + + string expectedAdjustmentID = "h74gfhdjvn7ujokd"; + + Assert.Equal(expectedAdjustmentID, model.AdjustmentID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedAdjustmentID = "h74gfhdjvn7ujokd"; + + Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); + } + + [Fact] + public void Validation_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionPackageWithAllocationPrice() - { - Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, - Name = "Annual fee", - PackageWithAllocationConfig = new() - { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; + + model.Validate(); } +} +public class RemovePriceTest : TestBase +{ [Fact] - public void NewSubscriptionUnitWithPercentValidationWorks() + public void FieldRoundtrip_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithPercentPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, - Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + var model = new Subscriptions::RemovePrice + { + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", + }; + + string expectedExternalPriceID = "external_price_id"; + string expectedPriceID = "h74gfhdjvn7ujokd"; + + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedPriceID, model.PriceID); } [Fact] - public void NewSubscriptionMatrixWithAllocationValidationWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() - { - Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, - ItemID = "item_id", - MatrixWithAllocationConfig = new() - { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = - [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + var model = new Subscriptions::RemovePrice + { + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void TieredWithProrationValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::ReplacePricePriceTieredWithProration() - { - Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + var model = new Subscriptions::RemovePrice + { + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedExternalPriceID = "external_price_id"; + string expectedPriceID = "h74gfhdjvn7ujokd"; + + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedPriceID, deserialized.PriceID); + } + + [Fact] + public void Validation_Works() + { + var model = new Subscriptions::RemovePrice + { + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Subscriptions::RemovePrice { }; + + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.PriceID); + Assert.False(model.RawData.ContainsKey("price_id")); } [Fact] - public void NewSubscriptionUnitWithProrationValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithProrationPrice() + var model = new Subscriptions::RemovePrice { }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Subscriptions::RemovePrice { ExternalPriceID = null, PriceID = null }; + + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.PriceID); + Assert.True(model.RawData.ContainsKey("price_id")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new Subscriptions::RemovePrice { ExternalPriceID = null, PriceID = null }; + + model.Validate(); + } +} + +public class ReplaceAdjustmentTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::ReplaceAdjustment + { + Adjustment = new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, - Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + }; + + Subscriptions::ReplaceAdjustmentAdjustment expectedAdjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }; + string expectedReplacesAdjustmentID = "replaces_adjustment_id"; + + Assert.Equal(expectedAdjustment, model.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); } [Fact] - public void NewSubscriptionGroupedAllocationValidationWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedAllocationPrice() + var model = new Subscriptions::ReplaceAdjustment + { + Adjustment = new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewSubscriptionBulkWithProrationValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionBulkWithProrationPrice() + var model = new Subscriptions::ReplaceAdjustment + { + Adjustment = new NewPercentageDiscount() { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + Subscriptions::ReplaceAdjustmentAdjustment expectedAdjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }; + string expectedReplacesAdjustmentID = "replaces_adjustment_id"; + + Assert.Equal(expectedAdjustment, deserialized.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); } [Fact] - public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() + public void Validation_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + var model = new Subscriptions::ReplaceAdjustment + { + Adjustment = new NewPercentageDiscount() { - Cadence = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + }; + + model.Validate(); + } +} + +public class ReplaceAdjustmentAdjustmentTest : TestBase +{ + [Fact] + public void NewPercentageDiscountValidationWorks() + { + Subscriptions::ReplaceAdjustmentAdjustment value = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }; value.Validate(); } [Fact] - public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() + public void NewUsageDiscountValidationWorks() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() - { - Cadence = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() - { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = - [ - new() - { - ScalingFactorValue = "scaling_factor", - ScalingValue = "scaling_value", - }, - ], - ScalingKey = "scaling_key", - UnitAmounts = - [ - new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, - ], - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + Subscriptions::ReplaceAdjustmentAdjustment value = new NewUsageDiscount() + { + AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, + UsageDiscount = 0, + AppliesToAll = NewUsageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + Field = NewUsageDiscountFilterField.PriceID, + Operator = NewUsageDiscountFilterOperator.Includes, + Values = ["string"], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + ], + IsInvoiceLevel = true, + PriceType = NewUsageDiscountPriceType.Usage, + }; value.Validate(); } [Fact] - public void GroupedWithMinMaxThresholdsValidationWorks() + public void NewAmountDiscountValidationWorks() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds() - { - Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + Subscriptions::ReplaceAdjustmentAdjustment value = new NewAmountDiscount() + { + AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, + AmountDiscount = "amount_discount", + AppliesToAll = AppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + Field = NewAmountDiscountFilterField.PriceID, + Operator = NewAmountDiscountFilterOperator.Includes, + Values = ["string"], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + ], + IsInvoiceLevel = true, + PriceType = PriceType.Usage, + }; value.Validate(); } [Fact] - public void NewSubscriptionMatrixWithDisplayNameValidationWorks() + public void NewMinimumValidationWorks() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() - { - Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, - ItemID = "item_id", - MatrixWithDisplayNameConfig = new() - { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + Subscriptions::ReplaceAdjustmentAdjustment value = new NewMinimum() + { + AdjustmentType = NewMinimumAdjustmentType.Minimum, + ItemID = "item_id", + MinimumAmount = "minimum_amount", + AppliesToAll = NewMinimumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + Field = NewMinimumFilterField.PriceID, + Operator = NewMinimumFilterOperator.Includes, + Values = ["string"], }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + ], + IsInvoiceLevel = true, + PriceType = NewMinimumPriceType.Usage, + }; + value.Validate(); + } + + [Fact] + public void NewMaximumValidationWorks() + { + Subscriptions::ReplaceAdjustmentAdjustment value = new NewMaximum() + { + AdjustmentType = NewMaximumAdjustmentType.Maximum, + MaximumAmount = "maximum_amount", + AppliesToAll = NewMaximumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + Field = NewMaximumFilterField.PriceID, + Operator = NewMaximumFilterOperator.Includes, + Values = ["string"], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + ], + IsInvoiceLevel = true, + PriceType = NewMaximumPriceType.Usage, + }; value.Validate(); } [Fact] - public void NewSubscriptionGroupedTieredPackageValidationWorks() + public void NewPercentageDiscountSerializationRoundtripWorks() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() - { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, - GroupedTieredPackageConfig = new() + Subscriptions::ReplaceAdjustmentAdjustment value = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewUsageDiscountSerializationRoundtripWorks() + { + Subscriptions::ReplaceAdjustmentAdjustment value = new NewUsageDiscount() + { + AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, + UsageDiscount = 0, + AppliesToAll = NewUsageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + Field = NewUsageDiscountFilterField.PriceID, + Operator = NewUsageDiscountFilterOperator.Includes, + Values = ["string"], }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() + ], + IsInvoiceLevel = true, + PriceType = NewUsageDiscountPriceType.Usage, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewAmountDiscountSerializationRoundtripWorks() + { + Subscriptions::ReplaceAdjustmentAdjustment value = new NewAmountDiscount() + { + AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, + AmountDiscount = "amount_discount", + AppliesToAll = AppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + Field = NewAmountDiscountFilterField.PriceID, + Operator = NewAmountDiscountFilterOperator.Includes, + Values = ["string"], }, - Currency = "currency", - DimensionalPriceConfiguration = new() + ], + IsInvoiceLevel = true, + PriceType = PriceType.Usage, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewMinimumSerializationRoundtripWorks() + { + Subscriptions::ReplaceAdjustmentAdjustment value = new NewMinimum() + { + AdjustmentType = NewMinimumAdjustmentType.Minimum, + ItemID = "item_id", + MinimumAmount = "minimum_amount", + AppliesToAll = NewMinimumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + Field = NewMinimumFilterField.PriceID, + Operator = NewMinimumFilterOperator.Includes, + Values = ["string"], }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + ], + IsInvoiceLevel = true, + PriceType = NewMinimumPriceType.Usage, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewMaximumSerializationRoundtripWorks() + { + Subscriptions::ReplaceAdjustmentAdjustment value = new NewMaximum() + { + AdjustmentType = NewMaximumAdjustmentType.Maximum, + MaximumAmount = "maximum_amount", + AppliesToAll = NewMaximumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + Field = NewMaximumFilterField.PriceID, + Operator = NewMaximumFilterOperator.Includes, + Values = ["string"], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + ], + IsInvoiceLevel = true, + PriceType = NewMaximumPriceType.Usage, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } +} +public class ReplacePriceTest : TestBase +{ [Fact] - public void NewSubscriptionMaxGroupTieredPackageValidationWorks() + public void FieldRoundtrip_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + var model = new Subscriptions::ReplacePrice + { + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], ItemID = "item_id", - MaxGroupTieredPackageConfig = new() + PerUnitCostBasis = "per_unit_cost_basis", + }, + Discounts = + [ + new() { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, }, - ModelType = - Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + ], + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 2, + MaximumAmount = "1.23", + MinimumAmount = "1.23", + Price = new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14149,38 +11802,56 @@ public void NewSubscriptionMaxGroupTieredPackageValidationWorks() }, Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }; - value.Validate(); - } + }, + PriceID = "h74gfhdjvn7ujokd", + }; - [Fact] - public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() - { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + string expectedReplacesPriceID = "replaces_price_id"; + NewAllocationPrice expectedAllocationPrice = new() + { + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, - Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - UnitPrice = "unit_price", - Prorate = true, - SecondDimension = "second_dimension", + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], }, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", + }; + List expectedDiscounts = + [ + new() + { + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, + }, + ]; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 2; + string expectedMaximumAmount = "1.23"; + string expectedMinimumAmount = "1.23"; + Subscriptions::ReplacePricePrice expectedPrice = + new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14212,40 +11883,74 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + string expectedPriceID = "h74gfhdjvn7ujokd"; + + Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); + Assert.Equal(expectedAllocationPrice, model.AllocationPrice); + Assert.NotNull(model.Discounts); + Assert.Equal(expectedDiscounts.Count, model.Discounts.Count); + for (int i = 0; i < expectedDiscounts.Count; i++) + { + Assert.Equal(expectedDiscounts[i], model.Discounts[i]); + } + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedMaximumAmount, model.MaximumAmount); + Assert.Equal(expectedMinimumAmount, model.MinimumAmount); + Assert.Equal(expectedPrice, model.Price); + Assert.Equal(expectedPriceID, model.PriceID); } [Fact] - public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + var model = new Subscriptions::ReplacePrice + { + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, - Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() + PerUnitCostBasis = "per_unit_cost_basis", + }, + Discounts = + [ + new() { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - SecondDimension = "second_dimension", + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, }, + ], + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 2, + MaximumAmount = "1.23", + MinimumAmount = "1.23", + Price = new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14276,34 +11981,69 @@ public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() }, Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }; - value.Validate(); + }, + PriceID = "h74gfhdjvn7ujokd", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewSubscriptionCumulativeGroupedBulkValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + var model = new Subscriptions::ReplacePrice + { + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + PerUnitCostBasis = "per_unit_cost_basis", + }, + Discounts = + [ + new() + { + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, + }, + ], + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 2, + MaximumAmount = "1.23", + MinimumAmount = "1.23", + Price = new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14334,26 +12074,63 @@ public void NewSubscriptionCumulativeGroupedBulkValidationWorks() }, Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }; - value.Validate(); - } + }, + PriceID = "h74gfhdjvn7ujokd", + }; - [Fact] - public void CumulativeGroupedAllocationValidationWorks() - { - Subscriptions::ReplacePricePrice value = - new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation() + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedReplacesPriceID = "replaces_price_id"; + NewAllocationPrice expectedAllocationPrice = new() + { + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { - Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], }, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", + }; + List expectedDiscounts = + [ + new() + { + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, + }, + ]; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 2; + string expectedMaximumAmount = "1.23"; + string expectedMinimumAmount = "1.23"; + Subscriptions::ReplacePricePrice expectedPrice = + new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14385,68 +12162,74 @@ public void CumulativeGroupedAllocationValidationWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); - } + string expectedPriceID = "h74gfhdjvn7ujokd"; - [Fact] - public void MinimumValidationWorks() - { - Subscriptions::ReplacePricePrice value = new Subscriptions::ReplacePricePriceMinimum() + Assert.Equal(expectedReplacesPriceID, deserialized.ReplacesPriceID); + Assert.Equal(expectedAllocationPrice, deserialized.AllocationPrice); + Assert.NotNull(deserialized.Discounts); + Assert.Equal(expectedDiscounts.Count, deserialized.Discounts.Count); + for (int i = 0; i < expectedDiscounts.Count; i++) { - Cadence = Subscriptions::ReplacePricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + Assert.Equal(expectedDiscounts[i], deserialized.Discounts[i]); + } + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedMaximumAmount, deserialized.MaximumAmount); + Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); + Assert.Equal(expectedPrice, deserialized.Price); + Assert.Equal(expectedPriceID, deserialized.PriceID); } [Fact] - public void NewSubscriptionMinimumCompositeValidationWorks() + public void Validation_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionMinimumCompositePrice() + var model = new Subscriptions::ReplacePrice + { + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], ItemID = "item_id", - MinimumCompositeConfig = new() + PerUnitCostBasis = "per_unit_cost_basis", + }, + Discounts = + [ + new() { - MinimumAmount = "minimum_amount", - Prorated = true, + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, }, - ModelType = - Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, + ], + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 2, + MaximumAmount = "1.23", + MinimumAmount = "1.23", + Price = new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14477,103 +12260,104 @@ public void NewSubscriptionMinimumCompositeValidationWorks() }, Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }; - value.Validate(); + }, + PriceID = "h74gfhdjvn7ujokd", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Subscriptions::ReplacePrice { ReplacesPriceID = "replaces_price_id" }; + + Assert.Null(model.AllocationPrice); + Assert.False(model.RawData.ContainsKey("allocation_price")); + Assert.Null(model.Discounts); + Assert.False(model.RawData.ContainsKey("discounts")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.MaximumAmount); + Assert.False(model.RawData.ContainsKey("maximum_amount")); + Assert.Null(model.MinimumAmount); + Assert.False(model.RawData.ContainsKey("minimum_amount")); + Assert.Null(model.Price); + Assert.False(model.RawData.ContainsKey("price")); + Assert.Null(model.PriceID); + Assert.False(model.RawData.ContainsKey("price_id")); } [Fact] - public void PercentValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Subscriptions::ReplacePricePrice value = new Subscriptions::ReplacePricePricePercent() + var model = new Subscriptions::ReplacePrice { ReplacesPriceID = "replaces_price_id" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Subscriptions::ReplacePrice { - Cadence = Subscriptions::ReplacePricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ReplacesPriceID = "replaces_price_id", + + AllocationPrice = null, + Discounts = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + MaximumAmount = null, + MinimumAmount = null, + Price = null, + PriceID = null, }; - value.Validate(); + + Assert.Null(model.AllocationPrice); + Assert.True(model.RawData.ContainsKey("allocation_price")); + Assert.Null(model.Discounts); + Assert.True(model.RawData.ContainsKey("discounts")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.MaximumAmount); + Assert.True(model.RawData.ContainsKey("maximum_amount")); + Assert.Null(model.MinimumAmount); + Assert.True(model.RawData.ContainsKey("minimum_amount")); + Assert.Null(model.Price); + Assert.True(model.RawData.ContainsKey("price")); + Assert.Null(model.PriceID); + Assert.True(model.RawData.ContainsKey("price_id")); } [Fact] - public void EventOutputValidationWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - Subscriptions::ReplacePricePrice value = new Subscriptions::ReplacePricePriceEventOutput() + var model = new Subscriptions::ReplacePrice { - Cadence = Subscriptions::ReplacePricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ReplacesPriceID = "replaces_price_id", + + AllocationPrice = null, + Discounts = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + MaximumAmount = null, + MinimumAmount = null, + Price = null, + PriceID = null, }; - value.Validate(); + + model.Validate(); } +} +public class ReplacePricePriceTest : TestBase +{ [Fact] - public void NewSubscriptionUnitSerializationRoundtripWorks() + public void NewSubscriptionUnitValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionUnitPrice() { @@ -14613,17 +12397,11 @@ public void NewSubscriptionUnitSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionTieredSerializationRoundtripWorks() + public void NewSubscriptionTieredValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionTieredPrice() { @@ -14675,17 +12453,11 @@ public void NewSubscriptionTieredSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionBulkSerializationRoundtripWorks() + public void NewSubscriptionBulkValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionBulkPrice() { @@ -14725,17 +12497,11 @@ public void NewSubscriptionBulkSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void BulkWithFiltersSerializationRoundtripWorks() + public void BulkWithFiltersValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::ReplacePricePriceBulkWithFilters() @@ -14783,17 +12549,11 @@ public void BulkWithFiltersSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionPackageSerializationRoundtripWorks() + public void NewSubscriptionPackageValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionPackagePrice() { @@ -14833,17 +12593,11 @@ public void NewSubscriptionPackageSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionMatrixSerializationRoundtripWorks() + public void NewSubscriptionMatrixValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionMatrixPrice() { @@ -14888,17 +12642,11 @@ public void NewSubscriptionMatrixSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() + public void NewSubscriptionThresholdTotalAmountValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() @@ -14948,17 +12696,11 @@ public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionTieredPackageSerializationRoundtripWorks() + public void NewSubscriptionTieredPackageValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionTieredPackagePrice() @@ -15007,17 +12749,11 @@ public void NewSubscriptionTieredPackageSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() + public void NewSubscriptionTieredWithMinimumValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionTieredWithMinimumPrice() @@ -15078,17 +12814,11 @@ public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() + public void NewSubscriptionGroupedTieredValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionGroupedTieredPrice() @@ -15137,17 +12867,11 @@ public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() + public void NewSubscriptionTieredPackageWithMinimumValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() @@ -15207,17 +12931,11 @@ public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() + public void NewSubscriptionPackageWithAllocationValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionPackageWithAllocationPrice() @@ -15264,17 +12982,11 @@ public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() + public void NewSubscriptionUnitWithPercentValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionUnitWithPercentPrice() @@ -15316,17 +13028,11 @@ public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() + public void NewSubscriptionMatrixWithAllocationValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() @@ -15377,17 +13083,11 @@ public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void TieredWithProrationSerializationRoundtripWorks() + public void TieredWithProrationValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::ReplacePricePriceTieredWithProration() @@ -15429,17 +13129,11 @@ public void TieredWithProrationSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() + public void NewSubscriptionUnitWithProrationValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionUnitWithProrationPrice() @@ -15481,17 +13175,11 @@ public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() + public void NewSubscriptionGroupedAllocationValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionGroupedAllocationPrice() @@ -15538,17 +13226,11 @@ public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() + public void NewSubscriptionBulkWithProrationValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionBulkWithProrationPrice() @@ -15595,17 +13277,11 @@ public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks() + public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() @@ -15653,17 +13329,11 @@ public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() @@ -15724,17 +13394,11 @@ public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks( Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() + public void GroupedWithMinMaxThresholdsValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds() @@ -15780,17 +13444,11 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() + public void NewSubscriptionMatrixWithDisplayNameValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() @@ -15844,17 +13502,11 @@ public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() + public void NewSubscriptionGroupedTieredPackageValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() @@ -15905,17 +13557,11 @@ public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() + public void NewSubscriptionMaxGroupTieredPackageValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() @@ -15966,17 +13612,11 @@ public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() @@ -16034,17 +13674,11 @@ public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWo Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() @@ -16105,17 +13739,11 @@ public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtrip Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() + public void NewSubscriptionCumulativeGroupedBulkValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() @@ -16169,17 +13797,11 @@ public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void CumulativeGroupedAllocationSerializationRoundtripWorks() + public void CumulativeGroupedAllocationValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation() @@ -16191,100 +13813,45 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() GroupAllocation = "group_allocation", GroupingKey = "x", UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void MinimumSerializationRoundtripWorks() - { - Subscriptions::ReplacePricePrice value = new Subscriptions::ReplacePricePriceMinimum() - { - Cadence = Subscriptions::ReplacePricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } [Fact] - public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() + public void NewSubscriptionMinimumCompositeValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionMinimumCompositePrice() @@ -16330,17 +13897,11 @@ public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void PercentSerializationRoundtripWorks() + public void PercentValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::ReplacePricePricePercent() { @@ -16379,17 +13940,11 @@ public void PercentSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void EventOutputSerializationRoundtripWorks() + public void EventOutputValidationWorks() { Subscriptions::ReplacePricePrice value = new Subscriptions::ReplacePricePriceEventOutput() { @@ -16433,6 +13988,50 @@ public void EventOutputSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionUnitSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize( element, @@ -16441,27 +14040,29 @@ public void EventOutputSerializationRoundtripWorks() Assert.Equal(value, deserialized); } -} -public class ReplacePricePriceBulkWithFiltersTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionTieredSerializationRoundtripWorks() { - var model = new Subscriptions::ReplacePricePriceBulkWithFilters + Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionTieredPrice() { - BulkWithFiltersConfig = new() + Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, + Name = "Annual fee", + TieredConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], Tiers = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, ], + Prorated = true, }, - Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16493,97 +14094,24 @@ public void FieldRoundtrip_Works() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = - new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - ApiEnum expectedCadence = - Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedBulkWithFiltersConfig, model.BulkWithFiltersConfig); - Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedItemID, model.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); - Assert.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); + Assert.Equal(value, deserialized); } [Fact] - public void SerializationRoundtrip_Works() + public void NewSubscriptionBulkSerializationRoundtripWorks() { - var model = new Subscriptions::ReplacePricePriceBulkWithFilters + Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionBulkPrice() { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, ItemID = "item_id", + ModelType = Subscriptions::ModelType.Bulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -16616,34 +14144,83 @@ public void SerializationRoundtrip_Works() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + Assert.Equal(value, deserialized); + } + + [Fact] + public void BulkWithFiltersSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::ReplacePricePriceBulkWithFilters() + { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Assert.Equal(model, deserialized); + Assert.Equal(value, deserialized); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewSubscriptionPackageSerializationRoundtripWorks() { - var model = new Subscriptions::ReplacePricePriceBulkWithFilters + Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionPackagePrice() { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, + Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16675,108 +14252,29 @@ public void FieldRoundtripThroughSerialization_Works() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = - new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - ApiEnum expectedCadence = - Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedBulkWithFiltersConfig, deserialized.BulkWithFiltersConfig); - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions ); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void NewSubscriptionMatrixSerializationRoundtripWorks() { - var model = new Subscriptions::ReplacePricePriceBulkWithFilters + Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionMatrixPrice() { - BulkWithFiltersConfig = new() + Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, + ItemID = "item_id", + MatrixConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -16809,655 +14307,1531 @@ public void Validation_Works() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - model.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() { - var model = new Subscriptions::ReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - }; - - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.False(model.RawData.ContainsKey("reference_id")); + Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void NewSubscriptionTieredPackageSerializationRoundtripWorks() { - var model = new Subscriptions::ReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionTieredPackagePrice() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - }; + Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, + Name = "Annual fee", + TieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - model.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() { - var model = new Subscriptions::ReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionTieredWithMinimumPrice() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; + Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, + Name = "Annual fee", + TieredWithMinimumConfig = new() + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + HideZeroAmountTiers = true, + Prorate = true, + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.True(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.True(model.RawData.ContainsKey("reference_id")); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() { - var model = new Subscriptions::ReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedTieredPrice() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; + Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, + GroupedTieredConfig = new() + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - model.Validate(); + Assert.Equal(value, deserialized); } -} -public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - List expectedFilters = - [ - new() { PropertyKey = "x", PropertyValue = "x" }, - ]; - List expectedTiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ]; + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + { + Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + Name = "Annual fee", + TieredPackageWithMinimumConfig = new() + { + PackageSize = 0, + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + ], + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Assert.Equal(expectedFilters.Count, model.Filters.Count); - for (int i = 0; i < expectedFilters.Count; i++) - { - Assert.Equal(expectedFilters[i], model.Filters[i]); - } - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } + Assert.Equal(value, deserialized); } [Fact] - public void SerializationRoundtrip_Works() + public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionPackageWithAllocationPrice() + { + Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, + Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Assert.Equal(model, deserialized); + Assert.Equal(value, deserialized); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - List expectedFilters = - [ - new() { PropertyKey = "x", PropertyValue = "x" }, - ]; - List expectedTiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ]; + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionUnitWithPercentPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, + Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Assert.Equal(expectedFilters.Count, deserialized.Filters.Count); - for (int i = 0; i < expectedFilters.Count; i++) - { - Assert.Equal(expectedFilters[i], deserialized.Filters[i]); - } - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); - } + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() + { + Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, + ItemID = "item_id", + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - model.Validate(); + Assert.Equal(value, deserialized); } -} -public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void TieredWithProrationSerializationRoundtripWorks() { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - { - PropertyKey = "x", - PropertyValue = "x", - }; - - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; + Subscriptions::ReplacePricePrice value = + new Subscriptions::ReplacePricePriceTieredWithProration() + { + Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Assert.Equal(expectedPropertyKey, model.PropertyKey); - Assert.Equal(expectedPropertyValue, model.PropertyValue); + Assert.Equal(value, deserialized); } [Fact] - public void SerializationRoundtrip_Works() + public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - { - PropertyKey = "x", - PropertyValue = "x", - }; + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionUnitWithProrationPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedAllocationPrice() + { + Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Assert.Equal(model, deserialized); + Assert.Equal(value, deserialized); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - { - PropertyKey = "x", - PropertyValue = "x", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionBulkWithProrationPrice() + { + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); - Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks() { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - { - PropertyKey = "x", - PropertyValue = "x", - }; + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + { + Cadence = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - model.Validate(); + Assert.Equal(value, deserialized); } -} -public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks() { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", - }; - - string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() + { + Cadence = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, + GroupedWithMeteredMinimumConfig = new() + { + GroupingKey = "x", + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = + [ + new() + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }, + ], + ScalingKey = "scaling_key", + UnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, + ], + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Assert.Equal(expectedUnitAmount, model.UnitAmount); - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(value, deserialized); } [Fact] - public void SerializationRoundtrip_Works() + public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + Subscriptions::ReplacePricePrice value = + new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds() + { + Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Assert.Equal(model, deserialized); + Assert.Equal(value, deserialized); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() + { + Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, + ItemID = "item_id", + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", - }; + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() + { + Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, + GroupedTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - model.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - }; + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + { + Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, + ItemID = "item_id", + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Assert.Null(model.TierLowerBound); - Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWorks() { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - }; + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + { + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + Prorate = true, + SecondDimension = "second_dimension", + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - model.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtripWorks() { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - - TierLowerBound = null, - }; + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + { + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + Name = "Annual fee", + ScalableMatrixWithTieredPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + SecondDimension = "second_dimension", + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Assert.Null(model.TierLowerBound); - Assert.True(model.RawData.ContainsKey("tier_lower_bound")); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() { - var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - - TierLowerBound = null, - }; - - model.Validate(); - } -} + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + { + Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); -public class ReplacePricePriceBulkWithFiltersCadenceTest : TestBase -{ - [Theory] - [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual)] - [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.SemiAnnual)] - [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Monthly)] - [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Quarterly)] - [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.OneTime)] - [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Custom)] - public void Validation_Works(Subscriptions::ReplacePricePriceBulkWithFiltersCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual)] - [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.SemiAnnual)] - [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Monthly)] - [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Quarterly)] - [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.OneTime)] - [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Custom)] - public void SerializationRoundtrip_Works( - Subscriptions::ReplacePricePriceBulkWithFiltersCadence rawValue - ) + public void CumulativeGroupedAllocationSerializationRoundtripWorks() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + Subscriptions::ReplacePricePrice value = + new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation() + { + Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionMinimumCompositePrice() + { + Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, + ItemID = "item_id", + MinimumCompositeConfig = new() + { + MinimumAmount = "minimum_amount", + Prorated = true, + }, + ModelType = + Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } -} -public class ReplacePricePriceBulkWithFiltersConversionRateConfigTest : TestBase -{ [Fact] - public void UnitValidationWorks() + public void PercentSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = - new SharedUnitConversionRateConfig() + Subscriptions::ReplacePricePrice value = new Subscriptions::ReplacePricePricePercent() + { + Cadence = Subscriptions::ReplacePricePricePercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() - { - Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = - new SharedTieredConversionRateConfig() + }, + Currency = "currency", + DimensionalPriceConfiguration = new() { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); - } - - [Fact] - public void UnitSerializationRoundtripWorks() - { - Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = - new SharedUnitConversionRateConfig() + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } [Fact] - public void TieredSerializationRoundtripWorks() + public void EventOutputSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = - new SharedTieredConversionRateConfig() + Subscriptions::ReplacePricePrice value = new Subscriptions::ReplacePricePriceEventOutput() + { + Cadence = Subscriptions::ReplacePricePriceEventOutputCadence.Annual, + EventOutputConfig = new() { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class ReplacePricePriceTieredWithProrationTest : TestBase +public class ReplacePricePriceBulkWithFiltersTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceTieredWithProration + var model = new Subscriptions::ReplacePricePriceBulkWithFilters { - Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -17490,15 +15864,21 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum< - string, - Subscriptions::ReplacePricePriceTieredWithProrationCadence - > expectedCadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual; + Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = + new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + ApiEnum expectedCadence = + Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; - Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = - new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -17507,7 +15887,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17531,11 +15911,11 @@ public void FieldRoundtrip_Works() Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; + Assert.Equal(expectedBulkWithFiltersConfig, model.BulkWithFiltersConfig); Assert.Equal(expectedCadence, model.Cadence); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -17561,14 +15941,20 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceTieredWithProration + var model = new Subscriptions::ReplacePricePriceBulkWithFilters { - Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -17603,7 +15989,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -17614,14 +16000,20 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::ReplacePricePriceTieredWithProration + var model = new Subscriptions::ReplacePricePriceBulkWithFilters { - Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -17656,21 +16048,27 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum< - string, - Subscriptions::ReplacePricePriceTieredWithProrationCadence - > expectedCadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual; + Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = + new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + ApiEnum expectedCadence = + Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; - Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = - new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -17679,7 +16077,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17703,11 +16101,11 @@ public void FieldRoundtripThroughSerialization_Works() Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; + Assert.Equal(expectedBulkWithFiltersConfig, deserialized.BulkWithFiltersConfig); Assert.Equal(expectedCadence, deserialized.Cadence); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -17736,14 +16134,20 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::ReplacePricePriceTieredWithProration + var model = new Subscriptions::ReplacePricePriceBulkWithFilters { - Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -17782,14 +16186,20 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::ReplacePricePriceTieredWithProration + var model = new Subscriptions::ReplacePricePriceBulkWithFilters { - Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; Assert.Null(model.BillableMetricID); @@ -17823,14 +16233,20 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::ReplacePricePriceTieredWithProration + var model = new Subscriptions::ReplacePricePriceBulkWithFilters { - Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; model.Validate(); @@ -17839,14 +16255,20 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::ReplacePricePriceTieredWithProration + var model = new Subscriptions::ReplacePricePriceBulkWithFilters { - Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -17892,137 +16314,266 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new Subscriptions::ReplacePricePriceBulkWithFilters + { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } +} + +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + List expectedFilters = + [ + new() { PropertyKey = "x", PropertyValue = "x" }, + ]; + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedFilters.Count, model.Filters.Count); + for (int i = 0; i < expectedFilters.Count; i++) + { + Assert.Equal(expectedFilters[i], model.Filters[i]); + } + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedFilters = + [ + new() { PropertyKey = "x", PropertyValue = "x" }, + ]; + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedFilters.Count, deserialized.Filters.Count); + for (int i = 0; i < expectedFilters.Count; i++) + { + Assert.Equal(expectedFilters[i], deserialized.Filters[i]); + } + Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + } + } + + [Fact] + public void Validation_Works() { - var model = new Subscriptions::ReplacePricePriceTieredWithProration + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig { - Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }; model.Validate(); } } -public class ReplacePricePriceTieredWithProrationCadenceTest : TestBase +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase { - [Theory] - [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual)] - [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.SemiAnnual)] - [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Monthly)] - [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Quarterly)] - [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.OneTime)] - [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Custom)] - public void Validation_Works( - Subscriptions::ReplacePricePriceTieredWithProrationCadence rawValue - ) + [Fact] + public void FieldRoundtrip_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = - rawValue; - value.Validate(); + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + string expectedPropertyKey = "x"; + string expectedPropertyValue = "x"; + + Assert.Equal(expectedPropertyKey, model.PropertyKey); + Assert.Equal(expectedPropertyValue, model.PropertyValue); } [Fact] - public void InvalidEnumValidationThrows_Works() + public void SerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } - [Theory] - [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual)] - [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.SemiAnnual)] - [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Monthly)] - [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Quarterly)] - [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.OneTime)] - [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Custom)] - public void SerializationRoundtrip_Works( - Subscriptions::ReplacePricePriceTieredWithProrationCadence rawValue - ) + [Fact] + public void FieldRoundtripThroughSerialization_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = - rawValue; + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); - Assert.Equal(value, deserialized); + string expectedPropertyKey = "x"; + string expectedPropertyValue = "x"; + + Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); + Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void Validation_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; - Assert.Equal(value, deserialized); + model.Validate(); } } -public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTest : TestBase +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; + string expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18033,127 +16584,160 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; + string expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); - } + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); } [Fact] public void Validation_Works() { - var model = new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + }; + + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, + }; + + Assert.Null(model.TierLowerBound); + Assert.True(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, }; model.Validate(); } } -public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierTest : TestBase +public class ReplacePricePriceBulkWithFiltersCadenceTest : TestBase { - [Fact] - public void FieldRoundtrip_Works() + [Theory] + [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual)] + [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.SemiAnnual)] + [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Monthly)] + [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Quarterly)] + [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.OneTime)] + [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Custom)] + public void Validation_Works(Subscriptions::ReplacePricePriceBulkWithFiltersCadence rawValue) { - var model = - new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; - - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; - - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void InvalidEnumValidationThrows_Works() { - var model = - new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - Assert.Equal(model, deserialized); + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); } - [Fact] - public void FieldRoundtripThroughSerialization_Works() + [Theory] + [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual)] + [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.SemiAnnual)] + [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Monthly)] + [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Quarterly)] + [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.OneTime)] + [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Custom)] + public void SerializationRoundtrip_Works( + Subscriptions::ReplacePricePriceBulkWithFiltersCadence rawValue + ) { - var model = - new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void InvalidEnumSerializationRoundtrip_Works() { - var model = - new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); - model.Validate(); + Assert.Equal(value, deserialized); } } -public class ReplacePricePriceTieredWithProrationConversionRateConfigTest : TestBase +public class ReplacePricePriceBulkWithFiltersConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18165,7 +16749,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -18186,7 +16770,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18194,7 +16778,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18205,7 +16789,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -18222,7 +16806,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18231,23 +16815,19 @@ public void TieredSerializationRoundtripWorks() } } -public class ReplacePricePriceGroupedWithMinMaxThresholdsTest : TestBase +public class ReplacePricePriceTieredWithProrationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds + var model = new Subscriptions::ReplacePricePriceTieredWithProration { - Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -18282,22 +16862,13 @@ public void FieldRoundtrip_Works() ApiEnum< string, - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence - > expectedCadence = - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = - new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + Subscriptions::ReplacePricePriceTieredWithProrationCadence + > expectedCadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; + Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -18306,7 +16877,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18331,13 +16902,10 @@ public void FieldRoundtrip_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal( - expectedGroupedWithMinMaxThresholdsConfig, - model.GroupedWithMinMaxThresholdsConfig - ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -18363,18 +16931,14 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds + var model = new Subscriptions::ReplacePricePriceTieredWithProration { - Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -18409,7 +16973,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18420,18 +16984,14 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds + var model = new Subscriptions::ReplacePricePriceTieredWithProration { - Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -18466,7 +17026,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18474,22 +17034,13 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence - > expectedCadence = - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = - new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + Subscriptions::ReplacePricePriceTieredWithProrationCadence + > expectedCadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; + Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -18498,7 +17049,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18523,13 +17074,10 @@ public void FieldRoundtripThroughSerialization_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal( - expectedGroupedWithMinMaxThresholdsConfig, - deserialized.GroupedWithMinMaxThresholdsConfig - ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -18558,18 +17106,14 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds + var model = new Subscriptions::ReplacePricePriceTieredWithProration { - Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -18608,18 +17152,14 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds + var model = new Subscriptions::ReplacePricePriceTieredWithProration { - Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; Assert.Null(model.BillableMetricID); @@ -18653,18 +17193,14 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds - { - Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + var model = new Subscriptions::ReplacePricePriceTieredWithProration + { + Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; model.Validate(); @@ -18673,18 +17209,14 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds + var model = new Subscriptions::ReplacePricePriceTieredWithProration { - Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -18732,18 +17264,14 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds + var model = new Subscriptions::ReplacePricePriceTieredWithProration { - Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -18764,21 +17292,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest : TestBase +public class ReplacePricePriceTieredWithProrationCadenceTest : TestBase { [Theory] - [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.SemiAnnual)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Monthly)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Quarterly)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.OneTime)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Custom)] public void Validation_Works( - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue + Subscriptions::ReplacePricePriceTieredWithProrationCadence rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = + ApiEnum value = rawValue; value.Validate(); } @@ -18787,7 +17315,7 @@ public void Validation_Works( public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -18795,23 +17323,23 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.SemiAnnual)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Monthly)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Quarterly)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.OneTime)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Custom)] public void SerializationRoundtrip_Works( - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue + Subscriptions::ReplacePricePriceTieredWithProrationCadence rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -18821,58 +17349,129 @@ public void SerializationRoundtrip_Works( public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest - : TestBase +public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + model.Validate(); + } +} + +public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18884,55 +17483,47 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); - Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); - Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { var model = - new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; model.Validate(); } } -public class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +public class ReplacePricePriceTieredWithProrationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18944,7 +17535,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -18965,7 +17556,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18973,7 +17564,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18984,7 +17575,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -19001,7 +17592,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19010,20 +17601,20 @@ public void TieredSerializationRoundtripWorks() } } -public class ReplacePricePriceCumulativeGroupedAllocationTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation + var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -19061,20 +17652,20 @@ public void FieldRoundtrip_Works() ApiEnum< string, - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence > expectedCadence = - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", + { GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" + "grouped_with_min_max_thresholds" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -19085,7 +17676,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19111,8 +17702,8 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedCadence, model.Cadence); Assert.Equal( - expectedCumulativeGroupedAllocationConfig, - model.CumulativeGroupedAllocationConfig + expectedGroupedWithMinMaxThresholdsConfig, + model.GroupedWithMinMaxThresholdsConfig ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); @@ -19142,15 +17733,15 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation + var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -19188,7 +17779,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -19199,15 +17790,15 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation + var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -19245,7 +17836,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19253,20 +17844,20 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence > expectedCadence = - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" + "grouped_with_min_max_thresholds" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -19277,7 +17868,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19303,8 +17894,8 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedCadence, deserialized.Cadence); Assert.Equal( - expectedCumulativeGroupedAllocationConfig, - deserialized.CumulativeGroupedAllocationConfig + expectedGroupedWithMinMaxThresholdsConfig, + deserialized.GroupedWithMinMaxThresholdsConfig ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); @@ -19337,15 +17928,15 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation + var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -19387,15 +17978,15 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation + var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -19432,15 +18023,15 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation + var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -19452,15 +18043,15 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation + var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -19511,15 +18102,15 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation + var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -19543,21 +18134,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class ReplacePricePriceCumulativeGroupedAllocationCadenceTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest : TestBase { [Theory] - [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] - [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] - [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] - [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] + [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] public void Validation_Works( - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence rawValue + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = + ApiEnum value = rawValue; value.Validate(); } @@ -19566,7 +18157,7 @@ public void Validation_Works( public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -19574,23 +18165,23 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] - [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] - [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] - [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] + [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] public void SerializationRoundtrip_Works( - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence rawValue + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -19600,58 +18191,58 @@ public void SerializationRoundtrip_Works( public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest +public class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedMaximumCharge, model.MaximumCharge); + Assert.Equal(expectedMinimumCharge, model.MinimumCharge); + Assert.Equal(expectedPerUnitRate, model.PerUnitRate); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -19663,55 +18254,55 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); + Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); + Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); } [Fact] public void Validation_Works() { var model = - new Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; model.Validate(); } } -public class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19723,7 +18314,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -19744,7 +18335,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19752,7 +18343,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19763,7 +18354,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -19780,7 +18371,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19789,16 +18380,22 @@ public void TieredSerializationRoundtripWorks() } } -public class ReplacePricePriceMinimumTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceMinimum + var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation { - Cadence = Subscriptions::ReplacePricePriceMinimumCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -19832,15 +18429,23 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - Subscriptions::ReplacePricePriceMinimumCadence.Annual; + ApiEnum< + string, + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence + > expectedCadence = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - Subscriptions::ReplacePricePriceMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -19850,7 +18455,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19875,8 +18480,11 @@ public void FieldRoundtrip_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + model.CumulativeGroupedAllocationConfig + ); Assert.Equal(expectedItemID, model.ItemID); - Assert.Equal(expectedMinimumConfig, model.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -19904,11 +18512,17 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceMinimum + var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation { - Cadence = Subscriptions::ReplacePricePriceMinimumCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -19943,10 +18557,11 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -19954,11 +18569,17 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::ReplacePricePriceMinimum + var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation { - Cadence = Subscriptions::ReplacePricePriceMinimumCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -19993,21 +18614,30 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = - Subscriptions::ReplacePricePriceMinimumCadence.Annual; + ApiEnum< + string, + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence + > expectedCadence = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - Subscriptions::ReplacePricePriceMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -20017,7 +18647,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20042,8 +18672,11 @@ public void FieldRoundtripThroughSerialization_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + deserialized.CumulativeGroupedAllocationConfig + ); Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.Equal(expectedMinimumConfig, deserialized.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -20074,11 +18707,17 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::ReplacePricePriceMinimum + var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation { - Cadence = Subscriptions::ReplacePricePriceMinimumCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -20118,11 +18757,17 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::ReplacePricePriceMinimum + var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation { - Cadence = Subscriptions::ReplacePricePriceMinimumCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", }; @@ -20157,11 +18802,17 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::ReplacePricePriceMinimum + var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation { - Cadence = Subscriptions::ReplacePricePriceMinimumCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", }; @@ -20171,11 +18822,17 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::ReplacePricePriceMinimum + var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation { - Cadence = Subscriptions::ReplacePricePriceMinimumCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = null, @@ -20224,11 +18881,17 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::ReplacePricePriceMinimum + var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation { - Cadence = Subscriptions::ReplacePricePriceMinimumCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = null, @@ -20250,19 +18913,22 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class ReplacePricePriceMinimumCadenceTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationCadenceTest : TestBase { [Theory] - [InlineData(Subscriptions::ReplacePricePriceMinimumCadence.Annual)] - [InlineData(Subscriptions::ReplacePricePriceMinimumCadence.SemiAnnual)] - [InlineData(Subscriptions::ReplacePricePriceMinimumCadence.Monthly)] - [InlineData(Subscriptions::ReplacePricePriceMinimumCadence.Quarterly)] - [InlineData(Subscriptions::ReplacePricePriceMinimumCadence.OneTime)] - [InlineData(Subscriptions::ReplacePricePriceMinimumCadence.Custom)] - public void Validation_Works(Subscriptions::ReplacePricePriceMinimumCadence rawValue) + [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] + [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] + public void Validation_Works( + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence rawValue + ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = + rawValue; value.Validate(); } @@ -20270,7 +18936,7 @@ public void Validation_Works(Subscriptions::ReplacePricePriceMinimumCadence rawV public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -20278,22 +18944,23 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(Subscriptions::ReplacePricePriceMinimumCadence.Annual)] - [InlineData(Subscriptions::ReplacePricePriceMinimumCadence.SemiAnnual)] - [InlineData(Subscriptions::ReplacePricePriceMinimumCadence.Monthly)] - [InlineData(Subscriptions::ReplacePricePriceMinimumCadence.Quarterly)] - [InlineData(Subscriptions::ReplacePricePriceMinimumCadence.OneTime)] - [InlineData(Subscriptions::ReplacePricePriceMinimumCadence.Custom)] + [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] + [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] public void SerializationRoundtrip_Works( - Subscriptions::ReplacePricePriceMinimumCadence rawValue + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = + rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -20303,47 +18970,58 @@ public void SerializationRoundtrip_Works( public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class ReplacePricePriceMinimumMinimumConfigTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = + new Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, model.GroupAllocation); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = + new Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -20354,98 +19032,56 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = + new Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { - var model = new Subscriptions::ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() - { - var model = new Subscriptions::ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() - { - var model = new Subscriptions::ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() - { - var model = new Subscriptions::ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; + var model = + new Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; model.Validate(); } } -public class ReplacePricePriceMinimumConversionRateConfigTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::ReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20457,7 +19093,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::ReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -20478,7 +19114,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20486,7 +19122,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -20497,7 +19133,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -20514,7 +19150,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchCostsParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchCostsParamsTest.cs index 1437c75c..12c3ea63 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchCostsParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchCostsParamsTest.cs @@ -92,6 +92,23 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionFetchCostsParams + { + SubscriptionID = "subscription_id", + Currency = "currency", + TimeframeEnd = DateTimeOffset.Parse("2022-03-01T05:00:00Z"), + TimeframeStart = DateTimeOffset.Parse("2022-02-01T05:00:00Z"), + ViewMode = ViewMode.Periodic, + }; + + SubscriptionFetchCostsParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class ViewModeTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchParamsTest.cs index 742f4a13..1a65dad7 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/subscriptions/subscription_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionFetchParams { SubscriptionID = "subscription_id" }; + + SubscriptionFetchParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchScheduleParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchScheduleParamsTest.cs index 0ac8499f..8fb8deac 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchScheduleParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchScheduleParamsTest.cs @@ -144,4 +144,23 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionFetchScheduleParams + { + SubscriptionID = "subscription_id", + Cursor = "cursor", + Limit = 1, + StartDateGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDateGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDateLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + SubscriptionFetchScheduleParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchUsageParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchUsageParamsTest.cs index 23af6df3..e86627fe 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchUsageParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchUsageParamsTest.cs @@ -147,6 +147,29 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionFetchUsageParams + { + SubscriptionID = "subscription_id", + BillableMetricID = "billable_metric_id", + FirstDimensionKey = "first_dimension_key", + FirstDimensionValue = "first_dimension_value", + Granularity = Granularity.Day, + GroupBy = "group_by", + SecondDimensionKey = "second_dimension_key", + SecondDimensionValue = "second_dimension_value", + TimeframeEnd = DateTimeOffset.Parse("2022-03-01T05:00:00Z"), + TimeframeStart = DateTimeOffset.Parse("2022-02-01T05:00:00Z"), + ViewMode = SubscriptionFetchUsageParamsViewMode.Periodic, + }; + + SubscriptionFetchUsageParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class GranularityTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionListParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionListParamsTest.cs index 7af61010..5d9aeba0 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionListParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionListParamsTest.cs @@ -202,6 +202,29 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionListParams + { + CreatedAtGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAtGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAtLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreatedAtLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Cursor = "cursor", + CustomerID = ["string"], + ExternalCustomerID = ["string"], + ExternalPlanID = "external_plan_id", + Limit = 1, + PlanID = "plan_id", + Status = Status.Active, + }; + + SubscriptionListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class StatusTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs index 73d6484b..d66ad3bd 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionPriceIntervalsParamsTest.cs @@ -720,6 +720,165 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new Subscriptions::SubscriptionPriceIntervalsParams + { + SubscriptionID = "subscription_id", + Add = + [ + new() + { + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + AllocationPrice = new() + { + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + CanDeferBilling = true, + Discounts = [new Subscriptions::Amount(0)], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalPriceID = "external_price_id", + Filter = "my_property > 100 AND my_other_property = 'bar'", + FixedFeeQuantityTransitions = + [ + new() + { + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Quantity = 5, + }, + ], + MaximumAmount = 0, + MinimumAmount = 0, + Price = new NewFloatingUnitPrice() + { + Cadence = NewFloatingUnitPriceCadence.Annual, + Currency = "currency", + ItemID = "item_id", + ModelType = NewFloatingUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = + SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + }, + PriceID = "h74gfhdjvn7ujokd", + UsageCustomerIds = ["string"], + }, + ], + AddAdjustments = + [ + new() + { + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + AdjustmentID = "h74gfhdjvn7ujokd", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + AllowInvoiceCreditOrVoid = true, + CanDeferBilling = true, + Edit = + [ + new() + { + PriceIntervalID = "sdfs6wdjvn7ujokd", + BillingCycleDay = 0, + CanDeferBilling = true, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Filter = "my_property > 100 AND my_other_property = 'bar'", + FixedFeeQuantityTransitions = + [ + new() + { + EffectiveDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Quantity = 5, + }, + ], + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + UsageCustomerIds = ["string"], + }, + ], + EditAdjustments = + [ + new() + { + AdjustmentIntervalID = "sdfs6wdjvn7ujokd", + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + }; + + Subscriptions::SubscriptionPriceIntervalsParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class AddTest : TestBase @@ -3245,48 +3404,6 @@ public void CumulativeGroupedAllocationValidationWorks() value.Validate(); } - [Fact] - public void MinimumValidationWorks() - { - Subscriptions::PriceModel value = new Subscriptions::PriceModelMinimum() - { - Cadence = Subscriptions::PriceModelMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - value.Validate(); - } - [Fact] public void NewFloatingMinimumCompositeValidationWorks() { @@ -5007,54 +5124,6 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Assert.Equal(value, deserialized); } - [Fact] - public void MinimumSerializationRoundtripWorks() - { - Subscriptions::PriceModel value = new Subscriptions::PriceModelMinimum() - { - Cadence = Subscriptions::PriceModelMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - [Fact] public void NewFloatingMinimumCompositeSerializationRoundtripWorks() { @@ -7710,722 +7779,6 @@ public void TieredSerializationRoundtripWorks() } } -public class PriceModelMinimumTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new Subscriptions::PriceModelMinimum - { - Cadence = Subscriptions::PriceModelMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - - ApiEnum expectedCadence = - Subscriptions::PriceModelMinimumCadence.Annual; - string expectedCurrency = "currency"; - string expectedItemID = "item_id"; - Subscriptions::PriceModelMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::PriceModelMinimumConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - - Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedItemID, model.ItemID); - Assert.Equal(expectedMinimumConfig, model.MinimumConfig); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); - Assert.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, model.Metadata[item.Key]); - } - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new Subscriptions::PriceModelMinimum - { - Cadence = Subscriptions::PriceModelMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new Subscriptions::PriceModelMinimum - { - Cadence = Subscriptions::PriceModelMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - ApiEnum expectedCadence = - Subscriptions::PriceModelMinimumCadence.Annual; - string expectedCurrency = "currency"; - string expectedItemID = "item_id"; - Subscriptions::PriceModelMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::PriceModelMinimumConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.Equal(expectedMinimumConfig, deserialized.MinimumConfig); - Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - } - - [Fact] - public void Validation_Works() - { - var model = new Subscriptions::PriceModelMinimum - { - Cadence = Subscriptions::PriceModelMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new Subscriptions::PriceModelMinimum - { - Cadence = Subscriptions::PriceModelMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - }; - - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::PriceModelMinimum - { - Cadence = Subscriptions::PriceModelMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new Subscriptions::PriceModelMinimum - { - Cadence = Subscriptions::PriceModelMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - }; - - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.True(model.RawData.ContainsKey("metadata")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new Subscriptions::PriceModelMinimum - { - Cadence = Subscriptions::PriceModelMinimumCadence.Annual, - Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - }; - - model.Validate(); - } -} - -public class PriceModelMinimumCadenceTest : TestBase -{ - [Theory] - [InlineData(Subscriptions::PriceModelMinimumCadence.Annual)] - [InlineData(Subscriptions::PriceModelMinimumCadence.SemiAnnual)] - [InlineData(Subscriptions::PriceModelMinimumCadence.Monthly)] - [InlineData(Subscriptions::PriceModelMinimumCadence.Quarterly)] - [InlineData(Subscriptions::PriceModelMinimumCadence.OneTime)] - [InlineData(Subscriptions::PriceModelMinimumCadence.Custom)] - public void Validation_Works(Subscriptions::PriceModelMinimumCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(Subscriptions::PriceModelMinimumCadence.Annual)] - [InlineData(Subscriptions::PriceModelMinimumCadence.SemiAnnual)] - [InlineData(Subscriptions::PriceModelMinimumCadence.Monthly)] - [InlineData(Subscriptions::PriceModelMinimumCadence.Quarterly)] - [InlineData(Subscriptions::PriceModelMinimumCadence.OneTime)] - [InlineData(Subscriptions::PriceModelMinimumCadence.Custom)] - public void SerializationRoundtrip_Works(Subscriptions::PriceModelMinimumCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } -} - -public class PriceModelMinimumMinimumConfigTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new Subscriptions::PriceModelMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; - - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new Subscriptions::PriceModelMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new Subscriptions::PriceModelMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; - - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); - } - - [Fact] - public void Validation_Works() - { - var model = new Subscriptions::PriceModelMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() - { - var model = new Subscriptions::PriceModelMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::PriceModelMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() - { - var model = new Subscriptions::PriceModelMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() - { - var model = new Subscriptions::PriceModelMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; - - model.Validate(); - } -} - -public class PriceModelMinimumConversionRateConfigTest : TestBase -{ - [Fact] - public void UnitValidationWorks() - { - Subscriptions::PriceModelMinimumConversionRateConfig value = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() - { - Subscriptions::PriceModelMinimumConversionRateConfig value = - new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); - } - - [Fact] - public void UnitSerializationRoundtripWorks() - { - Subscriptions::PriceModelMinimumConversionRateConfig value = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void TieredSerializationRoundtripWorks() - { - Subscriptions::PriceModelMinimumConversionRateConfig value = - new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - public class PriceModelPercentTest : TestBase { [Fact] diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionRedeemCouponParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionRedeemCouponParamsTest.cs index bafb1f50..9742f2a5 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionRedeemCouponParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionRedeemCouponParamsTest.cs @@ -95,6 +95,24 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionRedeemCouponParams + { + SubscriptionID = "subscription_id", + ChangeOption = ChangeOption.RequestedDate, + AllowInvoiceCreditOrVoid = true, + ChangeDate = DateTimeOffset.Parse("2017-07-21T17:32:28Z"), + CouponID = "coupon_id", + CouponRedemptionCode = "coupon_redemption_code", + }; + + SubscriptionRedeemCouponParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class ChangeOptionTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs index f1f3e6db..451cef5e 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionSchedulePlanChangeParamsTest.cs @@ -783,2282 +783,1049 @@ public void Url_Works() url ); } -} - -public class SubscriptionSchedulePlanChangeParamsChangeOptionTest : TestBase -{ - [Theory] - [InlineData(Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.RequestedDate)] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.EndOfSubscriptionTerm - )] - [InlineData(Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.Immediate)] - public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption rawValue - ) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = - rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.RequestedDate)] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.EndOfSubscriptionTerm - )] - [InlineData(Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.Immediate)] - public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption rawValue - ) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = - rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } -} - -public class SubscriptionSchedulePlanChangeParamsAddAdjustmentTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PlanPhaseOrder = 0, - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment expectedAdjustment = - new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }; - DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - long expectedPlanPhaseOrder = 0; - DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - - Assert.Equal(expectedAdjustment, model.Adjustment); - Assert.Equal(expectedEndDate, model.EndDate); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); - Assert.Equal(expectedStartDate, model.StartDate); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PlanPhaseOrder = 0, - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PlanPhaseOrder = 0, - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment expectedAdjustment = - new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }; - DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - long expectedPlanPhaseOrder = 0; - DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - - Assert.Equal(expectedAdjustment, deserialized.Adjustment); - Assert.Equal(expectedEndDate, deserialized.EndDate); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - Assert.Equal(expectedStartDate, deserialized.StartDate); - } - - [Fact] - public void Validation_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PlanPhaseOrder = 0, - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - }; - - Assert.Null(model.EndDate); - Assert.False(model.RawData.ContainsKey("end_date")); - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); - Assert.Null(model.StartDate); - Assert.False(model.RawData.ContainsKey("start_date")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - - EndDate = null, - PlanPhaseOrder = null, - StartDate = null, - }; - - Assert.Null(model.EndDate); - Assert.True(model.RawData.ContainsKey("end_date")); - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); - Assert.Null(model.StartDate); - Assert.True(model.RawData.ContainsKey("start_date")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - - EndDate = null, - PlanPhaseOrder = null, - StartDate = null, - }; - - model.Validate(); - } -} - -public class SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustmentTest : TestBase -{ - [Fact] - public void NewPercentageDiscountValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }; - value.Validate(); - } - - [Fact] - public void NewUsageDiscountValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewUsageDiscount() - { - AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewUsageDiscountFilterField.PriceID, - Operator = NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewUsageDiscountPriceType.Usage, - }; - value.Validate(); - } - - [Fact] - public void NewAmountDiscountValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewAmountDiscount() - { - AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewAmountDiscountFilterField.PriceID, - Operator = NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = PriceType.Usage, - }; - value.Validate(); - } - - [Fact] - public void NewMinimumValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewMinimum() - { - AdjustmentType = NewMinimumAdjustmentType.Minimum, - ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMinimumFilterField.PriceID, - Operator = NewMinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMinimumPriceType.Usage, - }; - value.Validate(); - } - - [Fact] - public void NewMaximumValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewMaximum() - { - AdjustmentType = NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMaximumFilterField.PriceID, - Operator = NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMaximumPriceType.Usage, - }; - value.Validate(); - } - - [Fact] - public void NewPercentageDiscountSerializationRoundtripWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewUsageDiscountSerializationRoundtripWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewUsageDiscount() - { - AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewUsageDiscountFilterField.PriceID, - Operator = NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewUsageDiscountPriceType.Usage, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewAmountDiscountSerializationRoundtripWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewAmountDiscount() - { - AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewAmountDiscountFilterField.PriceID, - Operator = NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = PriceType.Usage, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewMinimumSerializationRoundtripWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewMinimum() - { - AdjustmentType = NewMinimumAdjustmentType.Minimum, - ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMinimumFilterField.PriceID, - Operator = NewMinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMinimumPriceType.Usage, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewMaximumSerializationRoundtripWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewMaximum() - { - AdjustmentType = NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMaximumFilterField.PriceID, - Operator = NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMaximumPriceType.Usage, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - -public class SubscriptionSchedulePlanChangeParamsAddPriceTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice - { - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ], - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - ExternalPriceID = "external_price_id", - MaximumAmount = "1.23", - MinimumAmount = "1.23", - PlanPhaseOrder = 0, - Price = new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }, - PriceID = "h74gfhdjvn7ujokd", - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - NewAllocationPrice expectedAllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }; - List expectedDiscounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ]; - DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - string expectedExternalPriceID = "external_price_id"; - string expectedMaximumAmount = "1.23"; - string expectedMinimumAmount = "1.23"; - long expectedPlanPhaseOrder = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice expectedPrice = - new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string expectedPriceID = "h74gfhdjvn7ujokd"; - DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - - Assert.Equal(expectedAllocationPrice, model.AllocationPrice); - Assert.NotNull(model.Discounts); - Assert.Equal(expectedDiscounts.Count, model.Discounts.Count); - for (int i = 0; i < expectedDiscounts.Count; i++) - { - Assert.Equal(expectedDiscounts[i], model.Discounts[i]); - } - Assert.Equal(expectedEndDate, model.EndDate); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedMaximumAmount, model.MaximumAmount); - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); - Assert.Equal(expectedPrice, model.Price); - Assert.Equal(expectedPriceID, model.PriceID); - Assert.Equal(expectedStartDate, model.StartDate); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice - { - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ], - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - ExternalPriceID = "external_price_id", - MaximumAmount = "1.23", - MinimumAmount = "1.23", - PlanPhaseOrder = 0, - Price = new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }, - PriceID = "h74gfhdjvn7ujokd", - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice - { - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ], - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - ExternalPriceID = "external_price_id", - MaximumAmount = "1.23", - MinimumAmount = "1.23", - PlanPhaseOrder = 0, - Price = new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }, - PriceID = "h74gfhdjvn7ujokd", - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - NewAllocationPrice expectedAllocationPrice = new() + [Fact] + public void CopyConstructor_Works() + { + var parameters = new Subscriptions::SubscriptionSchedulePlanChangeParams { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = + SubscriptionID = "subscription_id", + ChangeOption = + Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.RequestedDate, + AddAdjustments = [ new() { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhaseOrder = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }, ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }; - List expectedDiscounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ]; - DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - string expectedExternalPriceID = "external_price_id"; - string expectedMaximumAmount = "1.23"; - string expectedMinimumAmount = "1.23"; - long expectedPlanPhaseOrder = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice expectedPrice = - new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string expectedPriceID = "h74gfhdjvn7ujokd"; - DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - - Assert.Equal(expectedAllocationPrice, deserialized.AllocationPrice); - Assert.NotNull(deserialized.Discounts); - Assert.Equal(expectedDiscounts.Count, deserialized.Discounts.Count); - for (int i = 0; i < expectedDiscounts.Count; i++) - { - Assert.Equal(expectedDiscounts[i], deserialized.Discounts[i]); - } - Assert.Equal(expectedEndDate, deserialized.EndDate); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedMaximumAmount, deserialized.MaximumAmount); - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - Assert.Equal(expectedPrice, deserialized.Price); - Assert.Equal(expectedPriceID, deserialized.PriceID); - Assert.Equal(expectedStartDate, deserialized.StartDate); - } - - [Fact] - public void Validation_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice - { - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() + AddPrices = + [ + new() { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() + AllocationPrice = new() { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", + Discounts = + [ + new() + { + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, + }, + ], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalPriceID = "external_price_id", + MaximumAmount = "1.23", + MinimumAmount = "1.23", + PlanPhaseOrder = 0, + Price = new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = + SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + PriceID = "h74gfhdjvn7ujokd", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + AlignBillingWithPlanChangeDate = true, + AutoCollection = true, + BillingCycleAlignment = Subscriptions::BillingCycleAlignment.Unchanged, + BillingCycleAnchorConfiguration = new() + { + Day = 1, + Month = 1, + Year = 0, }, - Discounts = + ChangeDate = DateTimeOffset.Parse("2017-07-21T17:32:28Z"), + CouponRedemptionCode = "coupon_redemption_code", + CreditsOverageRate = 0, + DefaultInvoiceMemo = "default_invoice_memo", + ExternalPlanID = "ZMwNQefe7J3ecf7W", + Filter = "my_property > 100 AND my_other_property = 'bar'", + InitialPhaseOrder = 2, + InvoicingThreshold = "10.00", + NetTerms = 0, + PerCreditOverageAmount = 0, + PlanID = "ZMwNQefe7J3ecf7W", + PlanVersionNumber = 0, + PriceOverrides = [JsonSerializer.Deserialize("{}")], + RemoveAdjustments = [new("h74gfhdjvn7ujokd")], + RemovePrices = + [ + new() { ExternalPriceID = "external_price_id", PriceID = "h74gfhdjvn7ujokd" }, + ], + ReplaceAdjustments = [ new() { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", }, ], - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - ExternalPriceID = "external_price_id", - MaximumAmount = "1.23", - MinimumAmount = "1.23", - PlanPhaseOrder = 0, - Price = new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + ReplacePrices = + [ + new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() + { + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + Discounts = + [ + new() + { + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, + }, + ], + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 2, + MaximumAmount = "1.23", + MinimumAmount = "1.23", + Price = new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = + SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + PriceID = "h74gfhdjvn7ujokd", }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }, - PriceID = "h74gfhdjvn7ujokd", - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ], + TrialDurationDays = 0, + UsageCustomerIds = ["string"], }; - model.Validate(); + Subscriptions::SubscriptionSchedulePlanChangeParams copied = new(parameters); + + Assert.Equal(parameters, copied); } +} - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() +public class SubscriptionSchedulePlanChangeParamsChangeOptionTest : TestBase +{ + [Theory] + [InlineData(Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.RequestedDate)] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.EndOfSubscriptionTerm + )] + [InlineData(Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.Immediate)] + public void Validation_Works( + Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption rawValue + ) { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice { }; - - Assert.Null(model.AllocationPrice); - Assert.False(model.RawData.ContainsKey("allocation_price")); - Assert.Null(model.Discounts); - Assert.False(model.RawData.ContainsKey("discounts")); - Assert.Null(model.EndDate); - Assert.False(model.RawData.ContainsKey("end_date")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.MaximumAmount); - Assert.False(model.RawData.ContainsKey("maximum_amount")); - Assert.Null(model.MinimumAmount); - Assert.False(model.RawData.ContainsKey("minimum_amount")); - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); - Assert.Null(model.Price); - Assert.False(model.RawData.ContainsKey("price")); - Assert.Null(model.PriceID); - Assert.False(model.RawData.ContainsKey("price_id")); - Assert.Null(model.StartDate); - Assert.False(model.RawData.ContainsKey("start_date")); + // force implicit conversion because Theory can't do that for us + ApiEnum value = + rawValue; + value.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void InvalidEnumValidationThrows_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice { }; + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - model.Validate(); + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); } - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + [Theory] + [InlineData(Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.RequestedDate)] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.EndOfSubscriptionTerm + )] + [InlineData(Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.Immediate)] + public void SerializationRoundtrip_Works( + Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption rawValue + ) { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice - { - AllocationPrice = null, - Discounts = null, - EndDate = null, - ExternalPriceID = null, - MaximumAmount = null, - MinimumAmount = null, - PlanPhaseOrder = null, - Price = null, - PriceID = null, - StartDate = null, - }; + // force implicit conversion because Theory can't do that for us + ApiEnum value = + rawValue; - Assert.Null(model.AllocationPrice); - Assert.True(model.RawData.ContainsKey("allocation_price")); - Assert.Null(model.Discounts); - Assert.True(model.RawData.ContainsKey("discounts")); - Assert.Null(model.EndDate); - Assert.True(model.RawData.ContainsKey("end_date")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.MaximumAmount); - Assert.True(model.RawData.ContainsKey("maximum_amount")); - Assert.Null(model.MinimumAmount); - Assert.True(model.RawData.ContainsKey("minimum_amount")); - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); - Assert.Null(model.Price); - Assert.True(model.RawData.ContainsKey("price")); - Assert.Null(model.PriceID); - Assert.True(model.RawData.ContainsKey("price_id")); - Assert.Null(model.StartDate); - Assert.True(model.RawData.ContainsKey("start_date")); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void InvalidEnumSerializationRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice - { - AllocationPrice = null, - Discounts = null, - EndDate = null, - ExternalPriceID = null, - MaximumAmount = null, - MinimumAmount = null, - PlanPhaseOrder = null, - Price = null, - PriceID = null, - StartDate = null, - }; + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); - model.Validate(); + Assert.Equal(value, deserialized); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddAdjustmentTest : TestBase { [Fact] - public void NewSubscriptionUnitValidationWorks() + public void FieldRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionUnitPrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + { + Adjustment = new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhaseOrder = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment expectedAdjustment = + new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }; - value.Validate(); + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + long expectedPlanPhaseOrder = 0; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + + Assert.Equal(expectedAdjustment, model.Adjustment); + Assert.Equal(expectedEndDate, model.EndDate); + Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); + Assert.Equal(expectedStartDate, model.StartDate); } [Fact] - public void NewSubscriptionTieredValidationWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredPrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + { + Adjustment = new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, - Name = "Annual fee", - TieredConfig = new() - { - Tiers = - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ], - Prorated = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhaseOrder = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + { + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhaseOrder = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment expectedAdjustment = + new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }; - value.Validate(); + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + long expectedPlanPhaseOrder = 0; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + + Assert.Equal(expectedAdjustment, deserialized.Adjustment); + Assert.Equal(expectedEndDate, deserialized.EndDate); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + Assert.Equal(expectedStartDate, deserialized.StartDate); } [Fact] - public void NewSubscriptionBulkValidationWorks() + public void Validation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionBulkPrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + { + Adjustment = new NewPercentageDiscount() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::ModelType.Bulk, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhaseOrder = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + model.Validate(); } [Fact] - public void BulkWithFiltersValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + { + Adjustment = new NewPercentageDiscount() { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + }; + + Assert.Null(model.EndDate); + Assert.False(model.RawData.ContainsKey("end_date")); + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.StartDate); + Assert.False(model.RawData.ContainsKey("start_date")); } [Fact] - public void NewSubscriptionPackageValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionPackagePrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + { + Adjustment = new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, - Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + }; + + model.Validate(); } [Fact] - public void NewSubscriptionMatrixValidationWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMatrixPrice() - { - Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, - ItemID = "item_id", - MatrixConfig = new() - { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = - [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, - ], - }, - ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + { + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + + EndDate = null, + PlanPhaseOrder = null, + StartDate = null, + }; + + Assert.Null(model.EndDate); + Assert.True(model.RawData.ContainsKey("end_date")); + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.StartDate); + Assert.True(model.RawData.ContainsKey("start_date")); } [Fact] - public void NewSubscriptionThresholdTotalAmountValidationWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + { + Adjustment = new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, - Name = "Annual fee", - ThresholdTotalAmountConfig = new() - { - ConsumptionTable = - [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - ], - Prorate = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + + EndDate = null, + PlanPhaseOrder = null, + StartDate = null, + }; + + model.Validate(); } +} +public class SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustmentTest : TestBase +{ [Fact] - public void NewSubscriptionTieredPackageValidationWorks() + public void NewPercentageDiscountValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredPackagePrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = + new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, - Name = "Annual fee", - TieredPackageConfig = new() - { - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }; value.Validate(); } [Fact] - public void NewSubscriptionTieredWithMinimumValidationWorks() + public void NewUsageDiscountValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredWithMinimumPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = + new NewUsageDiscount() { - Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, - Name = "Annual fee", - TieredWithMinimumConfig = new() - { - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - HideZeroAmountTiers = true, - Prorate = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, + UsageDiscount = 0, + AppliesToAll = NewUsageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewUsageDiscountFilterField.PriceID, + Operator = NewUsageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewUsageDiscountPriceType.Usage, }; value.Validate(); } [Fact] - public void NewSubscriptionGroupedTieredValidationWorks() + public void NewAmountDiscountValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = + new NewAmountDiscount() { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() - { - GroupingKey = "x", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - }, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, + AmountDiscount = "amount_discount", + AppliesToAll = AppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewAmountDiscountFilterField.PriceID, + Operator = NewAmountDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = PriceType.Usage, }; value.Validate(); } [Fact] - public void NewSubscriptionTieredPackageWithMinimumValidationWorks() + public void NewMinimumValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = + new NewMinimum() { - Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, + AdjustmentType = NewMinimumAdjustmentType.Minimum, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, - Name = "Annual fee", - TieredPackageWithMinimumConfig = new() - { - PackageSize = 0, - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - ], - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + MinimumAmount = "minimum_amount", + AppliesToAll = NewMinimumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewMinimumFilterField.PriceID, + Operator = NewMinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMinimumPriceType.Usage, }; value.Validate(); } [Fact] - public void NewSubscriptionPackageWithAllocationValidationWorks() + public void NewMaximumValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionPackageWithAllocationPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = + new NewMaximum() { - Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, - Name = "Annual fee", - PackageWithAllocationConfig = new() - { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewMaximumAdjustmentType.Maximum, + MaximumAmount = "maximum_amount", + AppliesToAll = NewMaximumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewMaximumFilterField.PriceID, + Operator = NewMaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMaximumPriceType.Usage, }; value.Validate(); } [Fact] - public void NewSubscriptionUnitWithPercentValidationWorks() + public void NewPercentageDiscountSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionUnitWithPercentPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = + new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, - Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewUsageDiscountSerializationRoundtripWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = + new NewUsageDiscount() + { + AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, + UsageDiscount = 0, + AppliesToAll = NewUsageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewUsageDiscountFilterField.PriceID, + Operator = NewUsageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewUsageDiscountPriceType.Usage, }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewSubscriptionMatrixWithAllocationValidationWorks() + public void NewAmountDiscountSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = + new NewAmountDiscount() { - Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, - ItemID = "item_id", - MatrixWithAllocationConfig = new() - { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = - [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, + AmountDiscount = "amount_discount", + AppliesToAll = AppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewAmountDiscountFilterField.PriceID, + Operator = NewAmountDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = PriceType.Usage, }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void TieredWithProrationValidationWorks() + public void NewMinimumSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = + new NewMinimum() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + AdjustmentType = NewMinimumAdjustmentType.Minimum, ItemID = "item_id", - Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + MinimumAmount = "minimum_amount", + AppliesToAll = NewMinimumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewMinimumFilterField.PriceID, + Operator = NewMinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMinimumPriceType.Usage, }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewSubscriptionUnitWithProrationValidationWorks() + public void NewMaximumSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionUnitWithProrationPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = + new NewMaximum() { - Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, - Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewMaximumAdjustmentType.Maximum, + MaximumAmount = "maximum_amount", + AppliesToAll = NewMaximumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewMaximumFilterField.PriceID, + Operator = NewMaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMaximumPriceType.Usage, }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } +} +public class SubscriptionSchedulePlanChangeParamsAddPriceTest : TestBase +{ [Fact] - public void NewSubscriptionGroupedAllocationValidationWorks() + public void FieldRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedAllocationPrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice + { + AllocationPrice = new() { - Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + DurationUnit = CustomExpirationDurationUnit.Day, }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + Discounts = + [ + new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionBulkWithProrationValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionBulkWithProrationPrice() + ], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalPriceID = "external_price_id", + MaximumAmount = "1.23", + MinimumAmount = "1.23", + PlanPhaseOrder = 0, + Price = new Subscriptions::NewSubscriptionUnitPrice() { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3089,28 +1856,57 @@ public void NewSubscriptionBulkWithProrationValidationWorks() }, Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }; - value.Validate(); - } + }, + PriceID = "h74gfhdjvn7ujokd", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; - [Fact] - public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + NewAllocationPrice expectedAllocationPrice = new() + { + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { - Cadence = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], }, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", + }; + List expectedDiscounts = + [ + new() + { + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, + }, + ]; + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedExternalPriceID = "external_price_id"; + string expectedMaximumAmount = "1.23"; + string expectedMinimumAmount = "1.23"; + long expectedPlanPhaseOrder = 0; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice expectedPrice = + new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3142,91 +1938,76 @@ public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + string expectedPriceID = "h74gfhdjvn7ujokd"; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + + Assert.Equal(expectedAllocationPrice, model.AllocationPrice); + Assert.NotNull(model.Discounts); + Assert.Equal(expectedDiscounts.Count, model.Discounts.Count); + for (int i = 0; i < expectedDiscounts.Count; i++) + { + Assert.Equal(expectedDiscounts[i], model.Discounts[i]); + } + Assert.Equal(expectedEndDate, model.EndDate); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedMaximumAmount, model.MaximumAmount); + Assert.Equal(expectedMinimumAmount, model.MinimumAmount); + Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); + Assert.Equal(expectedPrice, model.Price); + Assert.Equal(expectedPriceID, model.PriceID); + Assert.Equal(expectedStartDate, model.StartDate); } [Fact] - public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice + { + AllocationPrice = new() { - Cadence = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() - { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = - [ - new() - { - ScalingFactorValue = "scaling_factor", - ScalingValue = "scaling_value", - }, - ], - ScalingKey = "scaling_key", - UnitAmounts = - [ - new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, - ], - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + DurationUnit = CustomExpirationDurationUnit.Day, }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + Discounts = + [ + new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void GroupedWithMinMaxThresholdsValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds() + ], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalPriceID = "external_price_id", + MaximumAmount = "1.23", + MinimumAmount = "1.23", + PlanPhaseOrder = 0, + Price = new Subscriptions::NewSubscriptionUnitPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3257,34 +2038,71 @@ public void GroupedWithMinMaxThresholdsValidationWorks() }, Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }; - value.Validate(); + }, + PriceID = "h74gfhdjvn7ujokd", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewSubscriptionMatrixWithDisplayNameValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice + { + AllocationPrice = new() { - Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], ItemID = "item_id", - MatrixWithDisplayNameConfig = new() + PerUnitCostBasis = "per_unit_cost_basis", + }, + Discounts = + [ + new() { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + ], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalPriceID = "external_price_id", + MaximumAmount = "1.23", + MinimumAmount = "1.23", + PlanPhaseOrder = 0, + Price = new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3315,31 +2133,65 @@ public void NewSubscriptionMatrixWithDisplayNameValidationWorks() }, Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }; - value.Validate(); - } + }, + PriceID = "h74gfhdjvn7ujokd", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; - [Fact] - public void NewSubscriptionGroupedTieredPackageValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + NewAllocationPrice expectedAllocationPrice = new() + { + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, - GroupedTieredPackageConfig = new() + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], }, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", + }; + List expectedDiscounts = + [ + new() + { + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, + }, + ]; + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedExternalPriceID = "external_price_id"; + string expectedMaximumAmount = "1.23"; + string expectedMinimumAmount = "1.23"; + long expectedPlanPhaseOrder = 0; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice expectedPrice = + new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3371,30 +2223,76 @@ public void NewSubscriptionGroupedTieredPackageValidationWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + string expectedPriceID = "h74gfhdjvn7ujokd"; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + + Assert.Equal(expectedAllocationPrice, deserialized.AllocationPrice); + Assert.NotNull(deserialized.Discounts); + Assert.Equal(expectedDiscounts.Count, deserialized.Discounts.Count); + for (int i = 0; i < expectedDiscounts.Count; i++) + { + Assert.Equal(expectedDiscounts[i], deserialized.Discounts[i]); + } + Assert.Equal(expectedEndDate, deserialized.EndDate); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedMaximumAmount, deserialized.MaximumAmount); + Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + Assert.Equal(expectedPrice, deserialized.Price); + Assert.Equal(expectedPriceID, deserialized.PriceID); + Assert.Equal(expectedStartDate, deserialized.StartDate); } [Fact] - public void NewSubscriptionMaxGroupTieredPackageValidationWorks() + public void Validation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice + { + AllocationPrice = new() { - Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], ItemID = "item_id", - MaxGroupTieredPackageConfig = new() + PerUnitCostBasis = "per_unit_cost_basis", + }, + Discounts = + [ + new() { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, }, - ModelType = - Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + ], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalPriceID = "external_price_id", + MaximumAmount = "1.23", + MinimumAmount = "1.23", + PlanPhaseOrder = 0, + Price = new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3425,38 +2323,122 @@ public void NewSubscriptionMaxGroupTieredPackageValidationWorks() }, Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }; - value.Validate(); + }, + PriceID = "h74gfhdjvn7ujokd", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + model.Validate(); } [Fact] - public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice { }; + + Assert.Null(model.AllocationPrice); + Assert.False(model.RawData.ContainsKey("allocation_price")); + Assert.Null(model.Discounts); + Assert.False(model.RawData.ContainsKey("discounts")); + Assert.Null(model.EndDate); + Assert.False(model.RawData.ContainsKey("end_date")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.MaximumAmount); + Assert.False(model.RawData.ContainsKey("maximum_amount")); + Assert.Null(model.MinimumAmount); + Assert.False(model.RawData.ContainsKey("minimum_amount")); + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.Price); + Assert.False(model.RawData.ContainsKey("price")); + Assert.Null(model.PriceID); + Assert.False(model.RawData.ContainsKey("price_id")); + Assert.Null(model.StartDate); + Assert.False(model.RawData.ContainsKey("start_date")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice { }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice + { + AllocationPrice = null, + Discounts = null, + EndDate = null, + ExternalPriceID = null, + MaximumAmount = null, + MinimumAmount = null, + PlanPhaseOrder = null, + Price = null, + PriceID = null, + StartDate = null, + }; + + Assert.Null(model.AllocationPrice); + Assert.True(model.RawData.ContainsKey("allocation_price")); + Assert.Null(model.Discounts); + Assert.True(model.RawData.ContainsKey("discounts")); + Assert.Null(model.EndDate); + Assert.True(model.RawData.ContainsKey("end_date")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.MaximumAmount); + Assert.True(model.RawData.ContainsKey("maximum_amount")); + Assert.Null(model.MinimumAmount); + Assert.True(model.RawData.ContainsKey("minimum_amount")); + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.Price); + Assert.True(model.RawData.ContainsKey("price")); + Assert.Null(model.PriceID); + Assert.True(model.RawData.ContainsKey("price_id")); + Assert.Null(model.StartDate); + Assert.True(model.RawData.ContainsKey("start_date")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice + { + AllocationPrice = null, + Discounts = null, + EndDate = null, + ExternalPriceID = null, + MaximumAmount = null, + MinimumAmount = null, + PlanPhaseOrder = null, + Price = null, + PriceID = null, + StartDate = null, + }; + + model.Validate(); + } +} + +public class SubscriptionSchedulePlanChangeParamsAddPricePriceTest : TestBase +{ + [Fact] + public void NewSubscriptionUnitValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + new Subscriptions::NewSubscriptionUnitPrice() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - UnitPrice = "unit_price", - Prorate = true, - SecondDimension = "second_dimension", - }, + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3492,35 +2474,27 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() } [Fact] - public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() + public void NewSubscriptionTieredValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + new Subscriptions::NewSubscriptionTieredPrice() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() + TieredConfig = new() { - FirstDimension = "first_dimension", - MatrixScalingFactors = + Tiers = [ new() { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, }, ], - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - SecondDimension = "second_dimension", + Prorated = true, }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3557,28 +2531,15 @@ public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() } [Fact] - public void NewSubscriptionCumulativeGroupedBulkValidationWorks() + public void NewSubscriptionBulkValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + new Subscriptions::NewSubscriptionBulkPrice() { - Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() - { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + ModelType = Subscriptions::ModelType.Bulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3615,20 +2576,22 @@ public void NewSubscriptionCumulativeGroupedBulkValidationWorks() } [Fact] - public void CumulativeGroupedAllocationValidationWorks() + public void BulkWithFiltersValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + BulkWithFiltersConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -3666,16 +2629,16 @@ public void CumulativeGroupedAllocationValidationWorks() } [Fact] - public void MinimumValidationWorks() + public void NewSubscriptionPackageValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum() + new Subscriptions::NewSubscriptionPackagePrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3711,20 +2674,23 @@ public void MinimumValidationWorks() } [Fact] - public void NewSubscriptionMinimumCompositeValidationWorks() + public void NewSubscriptionMatrixValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMinimumCompositePrice() + new Subscriptions::NewSubscriptionMatrixPrice() { - Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, ItemID = "item_id", - MinimumCompositeConfig = new() + MatrixConfig = new() { - MinimumAmount = "minimum_amount", - Prorated = true, + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], }, - ModelType = - Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, + ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3761,16 +2727,25 @@ public void NewSubscriptionMinimumCompositeValidationWorks() } [Fact] - public void PercentValidationWorks() + public void NewSubscriptionThresholdTotalAmountValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent() + new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, Name = "Annual fee", - PercentConfig = new(0), + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3806,21 +2781,24 @@ public void PercentValidationWorks() } [Fact] - public void EventOutputValidationWorks() + public void NewSubscriptionTieredPackageValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() + new Subscriptions::NewSubscriptionTieredPackagePrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, Name = "Annual fee", + TieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3856,16 +2834,36 @@ public void EventOutputValidationWorks() } [Fact] - public void NewSubscriptionUnitSerializationRoundtripWorks() + public void NewSubscriptionTieredWithMinimumValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionUnitPrice() + new Subscriptions::NewSubscriptionTieredWithMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + ModelType = + Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + TieredWithMinimumConfig = new() + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + HideZeroAmountTiers = true, + Prorate = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3897,39 +2895,28 @@ public void NewSubscriptionUnitSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionTieredSerializationRoundtripWorks() + public void NewSubscriptionGroupedTieredValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredPrice() + new Subscriptions::NewSubscriptionGroupedTieredPrice() { - Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, - Name = "Annual fee", - TieredConfig = new() + Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, + GroupedTieredConfig = new() { + GroupingKey = "x", Tiers = [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], - Prorated = true, }, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3961,27 +2948,39 @@ public void NewSubscriptionTieredSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionBulkSerializationRoundtripWorks() + public void NewSubscriptionTieredPackageWithMinimumValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionBulkPrice() + new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::ModelType.Bulk, + ModelType = + Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, Name = "Annual fee", + TieredPackageWithMinimumConfig = new() + { + PackageSize = 0, + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + ], + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4013,35 +3012,26 @@ public void NewSubscriptionBulkSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void BulkWithFiltersSerializationRoundtripWorks() + public void NewSubscriptionPackageWithAllocationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters() + new Subscriptions::NewSubscriptionPackageWithAllocationPrice() { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, + Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4073,27 +3063,21 @@ public void BulkWithFiltersSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionPackageSerializationRoundtripWorks() + public void NewSubscriptionUnitWithPercentValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionPackagePrice() + new Subscriptions::NewSubscriptionUnitWithPercentPrice() { - Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, + ModelType = + Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4125,26 +3109,20 @@ public void NewSubscriptionPackageSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionMatrixSerializationRoundtripWorks() + public void NewSubscriptionMatrixWithAllocationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMatrixPrice() + new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() { - Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, ItemID = "item_id", - MatrixConfig = new() + MatrixWithAllocationConfig = new() { + Allocation = "allocation", DefaultUnitAmount = "default_unit_amount", Dimensions = ["string"], MatrixValues = @@ -4152,7 +3130,8 @@ public void NewSubscriptionMatrixSerializationRoundtripWorks() new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, ], }, - ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, + ModelType = + Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4185,36 +3164,22 @@ public void NewSubscriptionMatrixSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() + public void TieredWithProrationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration() { - Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, Name = "Annual fee", - ThresholdTotalAmountConfig = new() - { - ConsumptionTable = - [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - ], - Prorate = true, - }, + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4246,35 +3211,21 @@ public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionTieredPackageSerializationRoundtripWorks() + public void NewSubscriptionUnitWithProrationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredPackagePrice() - { - Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, - Name = "Annual fee", - TieredPackageConfig = new() - { - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], - }, + new Subscriptions::NewSubscriptionUnitWithProrationPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4306,47 +3257,26 @@ public void NewSubscriptionTieredPackageSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() + public void NewSubscriptionGroupedAllocationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredWithMinimumPrice() + new Subscriptions::NewSubscriptionGroupedAllocationPrice() { - Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, + Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", - TieredWithMinimumConfig = new() - { - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - HideZeroAmountTiers = true, - Prorate = true, - }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4378,34 +3308,25 @@ public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() + public void NewSubscriptionBulkWithProrationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPrice() + new Subscriptions::NewSubscriptionBulkWithProrationPrice() { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() - { - GroupingKey = "x", - Tiers = + BulkWithProrationConfig = new( [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, + ModelType = + Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4438,46 +3359,27 @@ public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() + public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, Name = "Annual fee", - TieredPackageWithMinimumConfig = new() - { - PackageSize = 0, - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - ], - }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4509,33 +3411,40 @@ public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() + public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionPackageWithAllocationPrice() + new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, + GroupedWithMeteredMinimumConfig = new() + { + GroupingKey = "x", + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = + [ + new() + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }, + ], + ScalingKey = "scaling_key", + UnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, + ], + }, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, Name = "Annual fee", - PackageWithAllocationConfig = new() - { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", - }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4567,28 +3476,26 @@ public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() + public void GroupedWithMinMaxThresholdsValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionUnitWithPercentPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds() { - Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4620,36 +3527,32 @@ public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() + public void NewSubscriptionMatrixWithDisplayNameValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() + new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() { - Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, ItemID = "item_id", - MatrixWithAllocationConfig = new() + MatrixWithDisplayNameConfig = new() { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = + Dimension = "dimension", + UnitAmounts = [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, ], }, ModelType = - Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, + Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4682,29 +3585,30 @@ public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void TieredWithProrationSerializationRoundtripWorks() + public void NewSubscriptionGroupedTieredPackageValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration() + new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, + GroupedTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, ItemID = "item_id", - Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + ModelType = + Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4736,28 +3640,30 @@ public void TieredWithProrationSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() + public void NewSubscriptionMaxGroupTieredPackageValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionUnitWithProrationPrice() + new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() { - Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, ItemID = "item_id", + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, ModelType = - Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, + Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4789,33 +3695,37 @@ public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() + public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedAllocationPrice() + new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() { - Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + Prorate = true, + SecondDimension = "second_dimension", + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4847,33 +3757,40 @@ public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() + public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionBulkWithProrationPrice() + new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, Name = "Annual fee", + ScalableMatrixWithTieredPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + SecondDimension = "second_dimension", + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4905,33 +3822,32 @@ public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks() + public void NewSubscriptionCumulativeGroupedBulkValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() { - Cadence = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() + Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", }, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4964,46 +3880,25 @@ public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void CumulativeGroupedAllocationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation() { Cadence = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = - [ - new() - { - ScalingFactorValue = "scaling_factor", - ScalingValue = "scaling_value", - }, - ], - ScalingKey = "scaling_key", - UnitAmounts = - [ - new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, - ], + UnitAmount = "unit_amount", }, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5036,32 +3931,24 @@ public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks( Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() + public void NewSubscriptionMinimumCompositeValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds() + new Subscriptions::NewSubscriptionMinimumCompositePrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, + ItemID = "item_id", + MinimumCompositeConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + MinimumAmount = "minimum_amount", + Prorated = true, }, - ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5094,40 +3981,20 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() + public void PercentValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent() { - Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", - MatrixWithDisplayNameConfig = new() - { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5154,41 +4021,29 @@ public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() InvoicingCycleConfiguration = new() { Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } [Fact] - public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() + public void EventOutputValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, - GroupedTieredPackageConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5221,37 +4076,20 @@ public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() + public void NewSubscriptionUnitSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + new Subscriptions::NewSubscriptionUnitPrice() { - Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - MaxGroupTieredPackageConfig = new() - { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5294,32 +4132,27 @@ public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void NewSubscriptionTieredSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + new Subscriptions::NewSubscriptionTieredPrice() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() + TieredConfig = new() { - FirstDimension = "first_dimension", - MatrixScalingFactors = + Tiers = [ new() { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, }, ], - UnitPrice = "unit_price", - Prorate = true, - SecondDimension = "second_dimension", + Prorated = true, }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5363,36 +4196,16 @@ public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWo } [Fact] - public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void NewSubscriptionBulkSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + new Subscriptions::NewSubscriptionBulkPrice() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + ModelType = Subscriptions::ModelType.Bulk, Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - SecondDimension = "second_dimension", - }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5435,28 +4248,23 @@ public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtrip } [Fact] - public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() + public void BulkWithFiltersSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters() { - Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() + BulkWithFiltersConfig = new() { - DimensionValues = + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], - Group = "group", }, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5500,22 +4308,16 @@ public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() } [Fact] - public void CumulativeGroupedAllocationSerializationRoundtripWorks() + public void NewSubscriptionPackageSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation() + new Subscriptions::NewSubscriptionPackagePrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5558,15 +4360,23 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void MinimumSerializationRoundtripWorks() + public void NewSubscriptionMatrixSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum() + new Subscriptions::NewSubscriptionMatrixPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, + ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5610,21 +4420,25 @@ public void MinimumSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() + public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMinimumCompositePrice() + new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() { - Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, ItemID = "item_id", - MinimumCompositeConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }, ModelType = - Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, + Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5667,16 +4481,24 @@ public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() } [Fact] - public void PercentSerializationRoundtripWorks() + public void NewSubscriptionTieredPackageSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent() + new Subscriptions::NewSubscriptionTieredPackagePrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, Name = "Annual fee", - PercentConfig = new(0), + TieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5719,21 +4541,36 @@ public void PercentSerializationRoundtripWorks() } [Fact] - public void EventOutputSerializationRoundtripWorks() + public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() + new Subscriptions::NewSubscriptionTieredWithMinimumPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, Name = "Annual fee", + TieredWithMinimumConfig = new() + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + HideZeroAmountTiers = true, + Prorate = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5774,28 +4611,25 @@ public void EventOutputSerializationRoundtripWorks() Assert.Equal(value, deserialized); } -} -public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionGroupedTieredPrice() { - BulkWithFiltersConfig = new() + Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, + GroupedTieredConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + GroupingKey = "x", Tiers = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5828,103 +4662,46 @@ public void FieldRoundtrip_Works() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = - new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence - > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedBulkWithFiltersConfig, model.BulkWithFiltersConfig); - Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedItemID, model.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); - Assert.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); + Assert.Equal(value, deserialized); } [Fact] - public void SerializationRoundtrip_Works() + public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() { - BulkWithFiltersConfig = new() + Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + Name = "Annual fee", + TieredPackageWithMinimumConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + PackageSize = 0, Tiers = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, ], }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5956,36 +4733,33 @@ public void SerializationRoundtrip_Works() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( - json, + JsonSerializer.Deserialize( + element, ModelBase.SerializerOptions ); - Assert.Equal(model, deserialized); + Assert.Equal(value, deserialized); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionPackageWithAllocationPrice() { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, + Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6017,114 +4791,28 @@ public void FieldRoundtripThroughSerialization_Works() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); - Assert.NotNull(deserialized); - - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = - new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence - > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedBulkWithFiltersConfig, deserialized.BulkWithFiltersConfig); - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionUnitWithPercentPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6156,678 +4844,1045 @@ public void Validation_Works() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - model.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() { - BulkWithFiltersConfig = new() + Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, + ItemID = "item_id", + MatrixWithAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, ], }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, Name = "Annual fee", - }; - - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.False(model.RawData.ContainsKey("reference_id")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; - - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.True(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.True(model.RawData.ContainsKey("reference_id")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() + Currency = "currency", + DimensionalPriceConfiguration = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; - - model.Validate(); - } -} - -public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTest - : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - List expectedFilters = - [ - new() { PropertyKey = "x", PropertyValue = "x" }, - ]; - List expectedTiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ]; - - Assert.Equal(expectedFilters.Count, model.Filters.Count); - for (int i = 0; i < expectedFilters.Count; i++) - { - Assert.Equal(expectedFilters[i], model.Filters[i]); - } - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( - json, + JsonSerializer.Deserialize( + element, ModelBase.SerializerOptions ); - Assert.Equal(model, deserialized); + Assert.Equal(value, deserialized); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void TieredWithProrationSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); - Assert.NotNull(deserialized); - - List expectedFilters = - [ - new() { PropertyKey = "x", PropertyValue = "x" }, - ]; - List expectedTiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ]; - Assert.Equal(expectedFilters.Count, deserialized.Filters.Count); - for (int i = 0; i < expectedFilters.Count; i++) - { - Assert.Equal(expectedFilters[i], deserialized.Filters[i]); - } - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); - } + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionUnitWithProrationPrice() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - model.Validate(); + Assert.Equal(value, deserialized); } -} -public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest - : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionGroupedAllocationPrice() { - PropertyKey = "x", - PropertyValue = "x", + Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; - - Assert.Equal(expectedPropertyKey, model.PropertyKey); - Assert.Equal(expectedPropertyValue, model.PropertyValue); + Assert.Equal(value, deserialized); } [Fact] - public void SerializationRoundtrip_Works() + public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionBulkWithProrationPrice() { - PropertyKey = "x", - PropertyValue = "x", + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( - json, + JsonSerializer.Deserialize( + element, ModelBase.SerializerOptions ); - Assert.Equal(model, deserialized); + Assert.Equal(value, deserialized); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() { - PropertyKey = "x", - PropertyValue = "x", + Cadence = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); - Assert.NotNull(deserialized); - - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; - Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); - Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() { - PropertyKey = "x", - PropertyValue = "x", + Cadence = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, + GroupedWithMeteredMinimumConfig = new() + { + GroupingKey = "x", + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = + [ + new() + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }, + ], + ScalingKey = "scaling_key", + UnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, + ], + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - model.Validate(); + Assert.Equal(value, deserialized); } -} -public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTierTest - : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds() { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; - - Assert.Equal(expectedUnitAmount, model.UnitAmount); - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(value, deserialized); } [Fact] - public void SerializationRoundtrip_Works() + public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, + ItemID = "item_id", + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( - json, + JsonSerializer.Deserialize( + element, ModelBase.SerializerOptions ); - Assert.Equal(model, deserialized); + Assert.Equal(value, deserialized); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, + GroupedTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); - Assert.NotNull(deserialized); - - string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; - - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - } - - [Fact] - public void Validation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - }; - - Assert.Null(model.TierLowerBound); - Assert.False(model.RawData.ContainsKey("tier_lower_bound")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - }; - model.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() { - UnitAmount = "unit_amount", - - TierLowerBound = null, + Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, + ItemID = "item_id", + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Assert.Null(model.TierLowerBound); - Assert.True(model.RawData.ContainsKey("tier_lower_bound")); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() { - UnitAmount = "unit_amount", - - TierLowerBound = null, + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + Prorate = true, + SecondDimension = "second_dimension", + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - model.Validate(); - } -} - -public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadenceTest : TestBase -{ - [Theory] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.SemiAnnual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Monthly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Quarterly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.OneTime - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Custom - )] - public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence rawValue - ) - { - // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence - > value = rawValue; - value.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void InvalidEnumValidationThrows_Works() + public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtripWorks() { - var value = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence - > - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + { + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + Name = "Annual fee", + ScalableMatrixWithTieredPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + SecondDimension = "second_dimension", + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); + Assert.Equal(value, deserialized); } - [Theory] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.SemiAnnual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Monthly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Quarterly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.OneTime - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Custom - )] - public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence rawValue - ) + [Fact] + public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() { - // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence - > value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence - > - >(json, ModelBase.SerializerOptions); + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + { + Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void CumulativeGroupedAllocationSerializationRoundtripWorks() { - var value = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence - > - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence - > - >(json, ModelBase.SerializerOptions); + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation() + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } -} -public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfigTest - : TestBase -{ [Fact] - public void UnitValidationWorks() + public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = - new SharedUnitConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionMinimumCompositePrice() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, + ItemID = "item_id", + MinimumCompositeConfig = new() + { + MinimumAmount = "minimum_amount", + Prorated = true, + }, + ModelType = + Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - value.Validate(); - } + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - [Fact] - public void TieredValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = - new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void UnitSerializationRoundtripWorks() + public void PercentSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = - new SharedUnitConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -6836,26 +5891,55 @@ public void UnitSerializationRoundtripWorks() } [Fact] - public void TieredSerializationRoundtripWorks() + public void EventOutputSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = - new SharedTieredConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -6864,21 +5948,27 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6911,16 +6001,24 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = + new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = - new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -6929,7 +6027,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6953,11 +6051,11 @@ public void FieldRoundtrip_Works() Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; + Assert.Equal(expectedBulkWithFiltersConfig, model.BulkWithFiltersConfig); Assert.Equal(expectedCadence, model.Cadence); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -6984,15 +6082,21 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -7027,7 +6131,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -7039,15 +6143,21 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -7082,22 +6192,30 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = + new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = - new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -7106,7 +6224,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7130,11 +6248,11 @@ public void FieldRoundtripThroughSerialization_Works() Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; + Assert.Equal(expectedBulkWithFiltersConfig, deserialized.BulkWithFiltersConfig); Assert.Equal(expectedCadence, deserialized.Cadence); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -7164,15 +6282,21 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -7212,15 +6336,21 @@ public void Validation_Works() public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; Assert.Null(model.BillableMetricID); @@ -7255,15 +6385,21 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; model.Validate(); @@ -7273,72 +6409,21 @@ public void OptionalNullablePropertiesUnsetValidation_Works() public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; - - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.True(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.True(model.RawData.ContainsKey("reference_id")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -7350,141 +6435,110 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ExternalPriceID = null, FixedPriceQuantity = null, InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; - - model.Validate(); - } -} - -public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadenceTest - : TestBase -{ - [Theory] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.SemiAnnual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Monthly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Quarterly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.OneTime - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Custom - )] - public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence rawValue - ) - { - // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence - > value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence - > - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.SemiAnnual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Monthly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Quarterly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.OneTime - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Custom - )] - public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence rawValue - ) - { - // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence - > value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence - > - >(json, ModelBase.SerializerOptions); + InvoicingCycleConfiguration = null, + Metadata = null, + ReferenceID = null, + }; - Assert.Equal(value, deserialized); + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.True(model.RawData.ContainsKey("reference_id")); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence - > - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence - > - >(json, ModelBase.SerializerOptions); + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", - Assert.Equal(value, deserialized); + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }; - List expectedTiers = + List expectedFilters = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { PropertyKey = "x", PropertyValue = "x" }, + ]; + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ]; + Assert.Equal(expectedFilters.Count, model.Filters.Count); + for (int i = 0; i < expectedFilters.Count; i++) + { + Assert.Equal(expectedFilters[i], model.Filters[i]); + } Assert.Equal(expectedTiers.Count, model.Tiers.Count); for (int i = 0; i < expectedTiers.Count; i++) { @@ -7496,14 +6550,19 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -7515,24 +6574,39 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - List expectedTiers = + List expectedFilters = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { PropertyKey = "x", PropertyValue = "x" }, + ]; + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ]; + Assert.Equal(expectedFilters.Count, deserialized.Filters.Count); + for (int i = 0; i < expectedFilters.Count; i++) + { + Assert.Equal(expectedFilters[i], deserialized.Filters[i]); + } Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); for (int i = 0; i < expectedTiers.Count; i++) { @@ -7544,48 +6618,53 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }; model.Validate(); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTierTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + PropertyKey = "x", + PropertyValue = "x", }; - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + string expectedPropertyKey = "x"; + string expectedPropertyValue = "x"; - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedPropertyKey, model.PropertyKey); + Assert.Equal(expectedPropertyValue, model.PropertyValue); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + PropertyKey = "x", + PropertyValue = "x", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -7597,503 +6676,114 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + PropertyKey = "x", + PropertyValue = "x", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; - - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); - } - - [Fact] - public void Validation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; - - model.Validate(); - } -} - -public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfigTest - : TestBase -{ - [Fact] - public void UnitValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = - new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); - } - - [Fact] - public void UnitSerializationRoundtripWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + string expectedPropertyKey = "x"; + string expectedPropertyValue = "x"; - Assert.Equal(value, deserialized); + Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); + Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); } [Fact] - public void TieredSerializationRoundtripWorks() + public void Validation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = - new SharedTieredConversionRateConfig() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), + PropertyKey = "x", + PropertyValue = "x", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence - > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = - new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal( - expectedGroupedWithMinMaxThresholdsConfig, - model.GroupedWithMinMaxThresholdsConfig - ); - Assert.Equal(expectedItemID, model.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); - Assert.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); + string expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence - > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = - new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal( - expectedGroupedWithMinMaxThresholdsConfig, - deserialized.GroupedWithMinMaxThresholdsConfig - ); - Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); + string expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); } [Fact] public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; model.Validate(); @@ -8103,66 +6793,22 @@ public void Validation_Works() public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", + UnitAmount = "unit_amount", }; - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.False(model.RawData.ContainsKey("reference_id")); + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", + UnitAmount = "unit_amount", }; model.Validate(); @@ -8172,130 +6818,61 @@ public void OptionalNullablePropertiesUnsetValidation_Works() public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; + UnitAmount = "unit_amount", - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.True(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.True(model.RawData.ContainsKey("reference_id")); + TierLowerBound = null, + }; + + Assert.Null(model.TierLowerBound); + Assert.True(model.RawData.ContainsKey("tier_lower_bound")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", + UnitAmount = "unit_amount", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + TierLowerBound = null, }; model.Validate(); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadenceTest - : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadenceTest : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence > value = rawValue; value.Validate(); } @@ -8306,7 +6883,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -8316,38 +6893,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence > >(json, ModelBase.SerializerOptions); @@ -8360,14 +6937,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence > >(json, ModelBase.SerializerOptions); @@ -8375,108 +6952,13 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest - : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; - - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; - - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; - - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); - Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); - Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); - } - - [Fact] - public void Validation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; - - model.Validate(); - } -} - -public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8488,7 +6970,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -8509,7 +6991,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8517,7 +6999,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8528,7 +7010,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -8545,7 +7027,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8554,26 +7036,21 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationTest - : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8608,22 +7085,14 @@ public void FieldRoundtrip_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = - new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -8632,7 +7101,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8657,13 +7126,10 @@ public void FieldRoundtrip_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal( - expectedCumulativeGroupedAllocationConfig, - model.CumulativeGroupedAllocationConfig - ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -8690,19 +7156,15 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8737,7 +7199,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -8749,19 +7211,15 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8796,7 +7254,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8804,22 +7262,14 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = - new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -8828,7 +7278,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8853,13 +7303,10 @@ public void FieldRoundtripThroughSerialization_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal( - expectedCumulativeGroupedAllocationConfig, - deserialized.CumulativeGroupedAllocationConfig - ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -8889,19 +7336,15 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8941,19 +7384,15 @@ public void Validation_Works() public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; Assert.Null(model.BillableMetricID); @@ -8988,19 +7427,15 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; model.Validate(); @@ -9010,19 +7445,15 @@ public void OptionalNullablePropertiesUnsetValidation_Works() public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -9071,19 +7502,15 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -9104,36 +7531,36 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadenceTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadenceTest : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence > value = rawValue; value.Validate(); } @@ -9144,7 +7571,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -9154,38 +7581,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence > >(json, ModelBase.SerializerOptions); @@ -9198,14 +7625,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence > >(json, ModelBase.SerializerOptions); @@ -9213,29 +7640,108 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + model.Validate(); + } +} + +public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTierTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; + string expectedTierLowerBound = "tier_lower_bound"; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); - Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); Assert.Equal(expectedUnitAmount, model.UnitAmount); } @@ -9243,17 +7749,15 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -9265,30 +7769,24 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; + string expectedTierLowerBound = "tier_lower_bound"; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } @@ -9296,11 +7794,9 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", }; @@ -9308,13 +7804,13 @@ public void Validation_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9326,7 +7822,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -9347,7 +7843,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9355,7 +7851,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9366,7 +7862,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -9383,7 +7879,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9392,59 +7888,75 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; string expectedItemID = "item_id"; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig expectedMinimumConfig = - new() { MinimumAmount = "minimum_amount", Prorated = true }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -9454,7 +7966,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9479,8 +7991,11 @@ public void FieldRoundtrip_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal( + expectedGroupedWithMinMaxThresholdsConfig, + model.GroupedWithMinMaxThresholdsConfig + ); Assert.Equal(expectedItemID, model.ItemID); - Assert.Equal(expectedMinimumConfig, model.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -9508,48 +8023,55 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -9560,48 +8082,55 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9609,13 +8138,21 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; string expectedItemID = "item_id"; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig expectedMinimumConfig = - new() { MinimumAmount = "minimum_amount", Prorated = true }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -9625,7 +8162,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9650,8 +8187,11 @@ public void FieldRoundtripThroughSerialization_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal( + expectedGroupedWithMinMaxThresholdsConfig, + deserialized.GroupedWithMinMaxThresholdsConfig + ); Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.Equal(expectedMinimumConfig, deserialized.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -9682,44 +8222,51 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; model.Validate(); } @@ -9727,14 +8274,21 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - }; + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + }; Assert.Null(model.BillableMetricID); Assert.False(model.RawData.ContainsKey("billable_metric_id")); @@ -9767,14 +8321,21 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - }; + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + }; model.Validate(); } @@ -9782,28 +8343,35 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + Metadata = null, + ReferenceID = null, + }; Assert.Null(model.BillableMetricID); Assert.True(model.RawData.ContainsKey("billable_metric_id")); @@ -9836,62 +8404,70 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + Metadata = null, + ReferenceID = null, + }; model.Validate(); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadenceTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadenceTest + : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > value = rawValue; value.Validate(); } @@ -9902,7 +8478,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -9912,38 +8488,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > >(json, ModelBase.SerializerOptions); @@ -9956,14 +8532,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > >(json, ModelBase.SerializerOptions); @@ -9971,38 +8547,47 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfigTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedGroupingKey = "x"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedMaximumCharge, model.MaximumCharge); + Assert.Equal(expectedMinimumCharge, model.MinimumCharge); + Assert.Equal(expectedPerUnitRate, model.PerUnitRate); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10014,104 +8599,56 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedGroupingKey = "x"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); + Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); + Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); } [Fact] public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; model.Validate(); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10123,7 +8660,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -10144,7 +8681,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10152,7 +8689,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10163,7 +8700,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -10180,7 +8717,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10189,60 +8726,76 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig expectedPercentConfig = - new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -10251,7 +8804,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10276,10 +8829,13 @@ public void FieldRoundtrip_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + model.CumulativeGroupedAllocationConfig + ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedPercentConfig, model.PercentConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -10304,49 +8860,56 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10357,48 +8920,55 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10406,14 +8976,22 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig expectedPercentConfig = - new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -10422,7 +9000,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10447,10 +9025,13 @@ public void FieldRoundtripThroughSerialization_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + deserialized.CumulativeGroupedAllocationConfig + ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedPercentConfig, deserialized.PercentConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -10479,44 +9060,51 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; model.Validate(); } @@ -10524,14 +9112,21 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - }; + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + }; Assert.Null(model.BillableMetricID); Assert.False(model.RawData.ContainsKey("billable_metric_id")); @@ -10564,14 +9159,21 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - }; + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + }; model.Validate(); } @@ -10579,28 +9181,35 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + Metadata = null, + ReferenceID = null, + }; Assert.Null(model.BillableMetricID); Assert.True(model.RawData.ContainsKey("billable_metric_id")); @@ -10633,62 +9242,70 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + Metadata = null, + ReferenceID = null, + }; model.Validate(); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadenceTest + : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > value = rawValue; value.Validate(); } @@ -10699,7 +9316,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -10709,38 +9326,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > >(json, ModelBase.SerializerOptions); @@ -10753,14 +9370,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > >(json, ModelBase.SerializerOptions); @@ -10768,34 +9385,47 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfigTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { - Percent = 0, + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; - double expectedPercent = 0; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedPercent, model.Percent); + Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, model.GroupAllocation); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { - Percent = 0, + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10807,44 +9437,56 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { - Percent = 0, + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - double expectedPercent = 0; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedPercent, deserialized.Percent); + Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { - Percent = 0, + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; model.Validate(); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10856,7 +9498,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -10877,7 +9519,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10885,7 +9527,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10896,7 +9538,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -10913,7 +9555,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10922,23 +9564,18 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentTest : TestBase { [Fact] - public void FieldRoundtrip_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -10973,19 +9610,14 @@ public void FieldRoundtrip_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig expectedEventOutputConfig = - new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); string expectedName = "Annual fee"; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig expectedPercentConfig = + new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -10994,7 +9626,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -11019,10 +9651,10 @@ public void FieldRoundtrip_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedEventOutputConfig, model.EventOutputConfig); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedPercentConfig, model.PercentConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -11048,18 +9680,13 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11094,7 +9721,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -11105,18 +9732,13 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11151,7 +9773,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -11159,19 +9781,14 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig expectedEventOutputConfig = - new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); string expectedName = "Annual fee"; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig expectedPercentConfig = + new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -11180,7 +9797,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -11205,10 +9822,10 @@ public void FieldRoundtripThroughSerialization_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedEventOutputConfig, deserialized.EventOutputConfig); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedPercentConfig, deserialized.PercentConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -11237,18 +9854,13 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11287,18 +9899,13 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), }; Assert.Null(model.BillableMetricID); @@ -11332,18 +9939,13 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), }; model.Validate(); @@ -11352,18 +9954,13 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -11411,18 +10008,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -11443,35 +10035,35 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadenceTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceTest : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > value = rawValue; value.Validate(); } @@ -11482,7 +10074,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -11492,38 +10084,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > >(json, ModelBase.SerializerOptions); @@ -11536,175 +10128,98 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > >(json, ModelBase.SerializerOptions); - Assert.Equal(value, deserialized); - } -} - -public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfigTest - : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; - - string expectedUnitRatingKey = "x"; - string expectedDefaultUnitRate = "default_unit_rate"; - string expectedGroupingKey = "grouping_key"; - - Assert.Equal(expectedUnitRatingKey, model.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, model.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, model.GroupingKey); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedUnitRatingKey = "x"; - string expectedDefaultUnitRate = "default_unit_rate"; - string expectedGroupingKey = "grouping_key"; - - Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - } - - [Fact] - public void Validation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; - - model.Validate(); + Assert.Equal(value, deserialized); } +} +public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfigTest : TestBase +{ [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig { - UnitRatingKey = "x", + Percent = 0, }; - Assert.Null(model.DefaultUnitRate); - Assert.False(model.RawData.ContainsKey("default_unit_rate")); - Assert.Null(model.GroupingKey); - Assert.False(model.RawData.ContainsKey("grouping_key")); + double expectedPercent = 0; + + Assert.Equal(expectedPercent, model.Percent); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig { - UnitRatingKey = "x", + Percent = 0, }; - model.Validate(); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig { - UnitRatingKey = "x", - - DefaultUnitRate = null, - GroupingKey = null, + Percent = 0, }; - Assert.Null(model.DefaultUnitRate); - Assert.True(model.RawData.ContainsKey("default_unit_rate")); - Assert.Null(model.GroupingKey); - Assert.True(model.RawData.ContainsKey("grouping_key")); + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedPercent = 0; + + Assert.Equal(expectedPercent, deserialized.Percent); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig { - UnitRatingKey = "x", - - DefaultUnitRate = null, - GroupingKey = null, + Percent = 0, }; model.Validate(); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -11716,7 +10231,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -11737,7 +10252,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -11745,7 +10260,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -11756,7 +10271,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -11773,7 +10288,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -11782,88 +10297,179 @@ public void TieredSerializationRoundtripWorks() } } -public class BillingCycleAlignmentTest : TestBase -{ - [Theory] - [InlineData(Subscriptions::BillingCycleAlignment.Unchanged)] - [InlineData(Subscriptions::BillingCycleAlignment.PlanChangeDate)] - [InlineData(Subscriptions::BillingCycleAlignment.StartOfMonth)] - public void Validation_Works(Subscriptions::BillingCycleAlignment rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(Subscriptions::BillingCycleAlignment.Unchanged)] - [InlineData(Subscriptions::BillingCycleAlignment.PlanChangeDate)] - [InlineData(Subscriptions::BillingCycleAlignment.StartOfMonth)] - public void SerializationRoundtrip_Works(Subscriptions::BillingCycleAlignment rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } -} - -public class SubscriptionSchedulePlanChangeParamsRemoveAdjustmentTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { - AdjustmentID = "h74gfhdjvn7ujokd", + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - string expectedAdjustmentID = "h74gfhdjvn7ujokd"; + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + > expectedCadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig expectedEventOutputConfig = + new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig expectedConversionRateConfig = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; - Assert.Equal(expectedAdjustmentID, model.AdjustmentID); + Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedEventOutputConfig, model.EventOutputConfig); + Assert.Equal(expectedItemID, model.ItemID); + Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedBillableMetricID, model.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, model.ConversionRate); + Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, model.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, model.ReferenceID); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { - AdjustmentID = "h74gfhdjvn7ujokd", + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -11874,244 +10480,489 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { - AdjustmentID = "h74gfhdjvn7ujokd", + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedAdjustmentID = "h74gfhdjvn7ujokd"; + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + > expectedCadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig expectedEventOutputConfig = + new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig expectedConversionRateConfig = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; - Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedEventOutputConfig, deserialized.EventOutputConfig); + Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); + Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); + Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); + Assert.Equal(expectedConversionRate, deserialized.ConversionRate); + Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); + foreach (var item in expectedMetadata) + { + Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); + + Assert.Equal(value, deserialized.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + } + + [Fact] + public void Validation_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.False(model.RawData.ContainsKey("reference_id")); } [Fact] - public void Validation_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { - AdjustmentID = "h74gfhdjvn7ujokd", + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", }; model.Validate(); } -} -public class SubscriptionSchedulePlanChangeParamsRemovePriceTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { - ExternalPriceID = "external_price_id", - PriceID = "h74gfhdjvn7ujokd", - }; - - string expectedExternalPriceID = "external_price_id"; - string expectedPriceID = "h74gfhdjvn7ujokd"; - - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedPriceID, model.PriceID); - } + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice - { - ExternalPriceID = "external_price_id", - PriceID = "h74gfhdjvn7ujokd", + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + Metadata = null, + ReferenceID = null, }; - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.True(model.RawData.ContainsKey("reference_id")); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { - ExternalPriceID = "external_price_id", - PriceID = "h74gfhdjvn7ujokd", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedExternalPriceID = "external_price_id"; - string expectedPriceID = "h74gfhdjvn7ujokd"; - - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedPriceID, deserialized.PriceID); - } + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", - [Fact] - public void Validation_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice - { - ExternalPriceID = "external_price_id", - PriceID = "h74gfhdjvn7ujokd", + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + Metadata = null, + ReferenceID = null, }; model.Validate(); } +} - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() +public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadenceTest : TestBase +{ + [Theory] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom + )] + public void Validation_Works( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence rawValue + ) { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { }; - - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.PriceID); - Assert.False(model.RawData.ContainsKey("price_id")); + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + > value = rawValue; + value.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void InvalidEnumValidationThrows_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { }; + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - model.Validate(); + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); } - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + [Theory] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom + )] + public void SerializationRoundtrip_Works( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence rawValue + ) { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice - { - ExternalPriceID = null, - PriceID = null, - }; + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + > value = rawValue; - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.PriceID); - Assert.True(model.RawData.ContainsKey("price_id")); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); } - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice - { - ExternalPriceID = null, - PriceID = null, - }; + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + > + >(json, ModelBase.SerializerOptions); - model.Validate(); + Assert.Equal(value, deserialized); } } -public class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfigTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - ReplacesAdjustmentID = "replaces_adjustment_id", - }; - - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment expectedAdjustment = - new NewPercentageDiscount() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; - Assert.Equal(expectedAdjustment, model.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); + string expectedUnitRatingKey = "x"; + string expectedDefaultUnitRate = "default_unit_rate"; + string expectedGroupingKey = "grouping_key"; + + Assert.Equal(expectedUnitRatingKey, model.UnitRatingKey); + Assert.Equal(expectedDefaultUnitRate, model.DefaultUnitRate); + Assert.Equal(expectedGroupingKey, model.GroupingKey); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment - { - Adjustment = new NewPercentageDiscount() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - ReplacesAdjustmentID = "replaces_adjustment_id", - }; + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -12122,331 +10973,154 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment - { - Adjustment = new NewPercentageDiscount() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - ReplacesAdjustmentID = "replaces_adjustment_id", - }; + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment expectedAdjustment = - new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; - - Assert.Equal(expectedAdjustment, deserialized.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); - } - - [Fact] - public void Validation_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - ReplacesAdjustmentID = "replaces_adjustment_id", - }; - - model.Validate(); - } -} + string expectedUnitRatingKey = "x"; + string expectedDefaultUnitRate = "default_unit_rate"; + string expectedGroupingKey = "grouping_key"; -public class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentTest : TestBase -{ - [Fact] - public void NewPercentageDiscountValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }; - value.Validate(); + Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); + Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); } - [Fact] - public void NewUsageDiscountValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewUsageDiscount() - { - AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewUsageDiscountFilterField.PriceID, - Operator = NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewUsageDiscountPriceType.Usage, + [Fact] + public void Validation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewAmountDiscountValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewAmountDiscount() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewAmountDiscountFilterField.PriceID, - Operator = NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = PriceType.Usage, + UnitRatingKey = "x", }; - value.Validate(); + + Assert.Null(model.DefaultUnitRate); + Assert.False(model.RawData.ContainsKey("default_unit_rate")); + Assert.Null(model.GroupingKey); + Assert.False(model.RawData.ContainsKey("grouping_key")); } [Fact] - public void NewMinimumValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewMinimum() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - AdjustmentType = NewMinimumAdjustmentType.Minimum, - ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMinimumFilterField.PriceID, - Operator = NewMinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMinimumPriceType.Usage, + UnitRatingKey = "x", }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewMaximumValidationWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewMaximum() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - AdjustmentType = NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMaximumFilterField.PriceID, - Operator = NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMaximumPriceType.Usage, + UnitRatingKey = "x", + + DefaultUnitRate = null, + GroupingKey = null, }; - value.Validate(); + + Assert.Null(model.DefaultUnitRate); + Assert.True(model.RawData.ContainsKey("default_unit_rate")); + Assert.Null(model.GroupingKey); + Assert.True(model.RawData.ContainsKey("grouping_key")); } [Fact] - public void NewPercentageDiscountSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewPercentageDiscount() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, + UnitRatingKey = "x", + + DefaultUnitRate = null, + GroupingKey = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } +} +public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigTest + : TestBase +{ [Fact] - public void NewUsageDiscountSerializationRoundtripWorks() + public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewUsageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = + new SharedUnitConversionRateConfig() { - AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewUsageDiscountFilterField.PriceID, - Operator = NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewUsageDiscountPriceType.Usage, + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + value.Validate(); + } - Assert.Equal(value, deserialized); + [Fact] + public void TieredValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); } [Fact] - public void NewAmountDiscountSerializationRoundtripWorks() + public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewAmountDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = + new SharedUnitConversionRateConfig() { - AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewAmountDiscountFilterField.PriceID, - Operator = NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = PriceType.Usage, + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -12455,343 +11129,116 @@ public void NewAmountDiscountSerializationRoundtripWorks() } [Fact] - public void NewMinimumSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewMinimum() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = + new SharedTieredConversionRateConfig() { - AdjustmentType = NewMinimumAdjustmentType.Minimum, - ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMinimumFilterField.PriceID, - Operator = NewMinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMinimumPriceType.Usage, + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.Equal(value, deserialized); } +} + +public class BillingCycleAlignmentTest : TestBase +{ + [Theory] + [InlineData(Subscriptions::BillingCycleAlignment.Unchanged)] + [InlineData(Subscriptions::BillingCycleAlignment.PlanChangeDate)] + [InlineData(Subscriptions::BillingCycleAlignment.StartOfMonth)] + public void Validation_Works(Subscriptions::BillingCycleAlignment rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } [Fact] - public void NewMaximumSerializationRoundtripWorks() + public void InvalidEnumValidationThrows_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewMaximum() - { - AdjustmentType = NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMaximumFilterField.PriceID, - Operator = NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMaximumPriceType.Usage, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Subscriptions::BillingCycleAlignment.Unchanged)] + [InlineData(Subscriptions::BillingCycleAlignment.PlanChangeDate)] + [InlineData(Subscriptions::BillingCycleAlignment.StartOfMonth)] + public void SerializationRoundtrip_Works(Subscriptions::BillingCycleAlignment rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } -} -public class SubscriptionSchedulePlanChangeParamsReplacePriceTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void InvalidEnumSerializationRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice - { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ], - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 2, - MaximumAmount = "1.23", - MinimumAmount = "1.23", - Price = new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }, - PriceID = "h74gfhdjvn7ujokd", - }; + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); - string expectedReplacesPriceID = "replaces_price_id"; - NewAllocationPrice expectedAllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }; - List expectedDiscounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ]; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 2; - string expectedMaximumAmount = "1.23"; - string expectedMinimumAmount = "1.23"; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice expectedPrice = - new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string expectedPriceID = "h74gfhdjvn7ujokd"; + Assert.Equal(value, deserialized); + } +} - Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); - Assert.Equal(expectedAllocationPrice, model.AllocationPrice); - Assert.NotNull(model.Discounts); - Assert.Equal(expectedDiscounts.Count, model.Discounts.Count); - for (int i = 0; i < expectedDiscounts.Count; i++) - { - Assert.Equal(expectedDiscounts[i], model.Discounts[i]); - } - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedMaximumAmount, model.MaximumAmount); - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedPrice, model.Price); - Assert.Equal(expectedPriceID, model.PriceID); +public class SubscriptionSchedulePlanChangeParamsRemoveAdjustmentTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment + { + AdjustmentID = "h74gfhdjvn7ujokd", + }; + + string expectedAdjustmentID = "h74gfhdjvn7ujokd"; + + Assert.Equal(expectedAdjustmentID, model.AdjustmentID); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ], - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 2, - MaximumAmount = "1.23", - MinimumAmount = "1.23", - Price = new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }, - PriceID = "h74gfhdjvn7ujokd", + AdjustmentID = "h74gfhdjvn7ujokd", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -12802,271 +11249,103 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ], - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 2, - MaximumAmount = "1.23", - MinimumAmount = "1.23", - Price = new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }, - PriceID = "h74gfhdjvn7ujokd", + AdjustmentID = "h74gfhdjvn7ujokd", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedReplacesPriceID = "replaces_price_id"; - NewAllocationPrice expectedAllocationPrice = new() + string expectedAdjustmentID = "h74gfhdjvn7ujokd"; + + Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); + } + + [Fact] + public void Validation_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", + AdjustmentID = "h74gfhdjvn7ujokd", + }; + + model.Validate(); + } +} + +public class SubscriptionSchedulePlanChangeParamsRemovePriceTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice + { + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", + }; + + string expectedExternalPriceID = "external_price_id"; + string expectedPriceID = "h74gfhdjvn7ujokd"; + + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedPriceID, model.PriceID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice + { + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice + { + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", }; - List expectedDiscounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ]; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 2; - string expectedMaximumAmount = "1.23"; - string expectedMinimumAmount = "1.23"; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice expectedPrice = - new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; string expectedPriceID = "h74gfhdjvn7ujokd"; - Assert.Equal(expectedReplacesPriceID, deserialized.ReplacesPriceID); - Assert.Equal(expectedAllocationPrice, deserialized.AllocationPrice); - Assert.NotNull(deserialized.Discounts); - Assert.Equal(expectedDiscounts.Count, deserialized.Discounts.Count); - for (int i = 0; i < expectedDiscounts.Count; i++) - { - Assert.Equal(expectedDiscounts[i], deserialized.Discounts[i]); - } Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedMaximumAmount, deserialized.MaximumAmount); - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedPrice, deserialized.Price); Assert.Equal(expectedPriceID, deserialized.PriceID); } [Fact] public void Validation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ], ExternalPriceID = "external_price_id", - FixedPriceQuantity = 2, - MaximumAmount = "1.23", - MinimumAmount = "1.23", - Price = new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }, PriceID = "h74gfhdjvn7ujokd", }; @@ -13076,25 +11355,10 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice - { - ReplacesPriceID = "replaces_price_id", - }; + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { }; - Assert.Null(model.AllocationPrice); - Assert.False(model.RawData.ContainsKey("allocation_price")); - Assert.Null(model.Discounts); - Assert.False(model.RawData.ContainsKey("discounts")); Assert.Null(model.ExternalPriceID); Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.MaximumAmount); - Assert.False(model.RawData.ContainsKey("maximum_amount")); - Assert.Null(model.MinimumAmount); - Assert.False(model.RawData.ContainsKey("minimum_amount")); - Assert.Null(model.Price); - Assert.False(model.RawData.ContainsKey("price")); Assert.Null(model.PriceID); Assert.False(model.RawData.ContainsKey("price_id")); } @@ -13102,10 +11366,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice - { - ReplacesPriceID = "replaces_price_id", - }; + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { }; model.Validate(); } @@ -13113,34 +11374,14 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { - ReplacesPriceID = "replaces_price_id", - - AllocationPrice = null, - Discounts = null, ExternalPriceID = null, - FixedPriceQuantity = null, - MaximumAmount = null, - MinimumAmount = null, - Price = null, PriceID = null, }; - Assert.Null(model.AllocationPrice); - Assert.True(model.RawData.ContainsKey("allocation_price")); - Assert.Null(model.Discounts); - Assert.True(model.RawData.ContainsKey("discounts")); Assert.Null(model.ExternalPriceID); Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.MaximumAmount); - Assert.True(model.RawData.ContainsKey("maximum_amount")); - Assert.Null(model.MinimumAmount); - Assert.True(model.RawData.ContainsKey("minimum_amount")); - Assert.Null(model.Price); - Assert.True(model.RawData.ContainsKey("price")); Assert.Null(model.PriceID); Assert.True(model.RawData.ContainsKey("price_id")); } @@ -13148,875 +11389,568 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { - ReplacesPriceID = "replaces_price_id", - - AllocationPrice = null, - Discounts = null, ExternalPriceID = null, - FixedPriceQuantity = null, - MaximumAmount = null, - MinimumAmount = null, - Price = null, PriceID = null, - }; - - model.Validate(); - } -} - -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTest : TestBase -{ - [Fact] - public void NewSubscriptionUnitValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + }; + + model.Validate(); } +} +public class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentTest : TestBase +{ [Fact] - public void NewSubscriptionTieredValidationWorks() + public void FieldRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment + { + Adjustment = new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, - Name = "Annual fee", - TieredConfig = new() - { - Tiers = - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ], - Prorated = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + }; - [Fact] - public void NewSubscriptionBulkValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionBulkPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment expectedAdjustment = + new NewPercentageDiscount() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::ModelType.Bulk, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }; - value.Validate(); + string expectedReplacesAdjustmentID = "replaces_adjustment_id"; + + Assert.Equal(expectedAdjustment, model.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); } [Fact] - public void BulkWithFiltersValidationWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment + { + Adjustment = new NewPercentageDiscount() { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewSubscriptionPackageValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionPackagePrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment + { + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment expectedAdjustment = + new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, - Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }; - value.Validate(); + string expectedReplacesAdjustmentID = "replaces_adjustment_id"; + + Assert.Equal(expectedAdjustment, deserialized.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); } [Fact] - public void NewSubscriptionMatrixValidationWorks() + public void Validation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixPrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment + { + Adjustment = new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, - ItemID = "item_id", - MatrixConfig = new() - { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = - [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, - ], - }, - ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + }; + + model.Validate(); } +} +public class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentTest : TestBase +{ [Fact] - public void NewSubscriptionThresholdTotalAmountValidationWorks() + public void NewPercentageDiscountValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, - Name = "Annual fee", - ThresholdTotalAmountConfig = new() - { - ConsumptionTable = - [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - ], - Prorate = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }; value.Validate(); } [Fact] - public void NewSubscriptionTieredPackageValidationWorks() + public void NewUsageDiscountValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackagePrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewUsageDiscount() { - Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, - Name = "Annual fee", - TieredPackageConfig = new() - { - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, + UsageDiscount = 0, + AppliesToAll = NewUsageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewUsageDiscountFilterField.PriceID, + Operator = NewUsageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewUsageDiscountPriceType.Usage, }; value.Validate(); } [Fact] - public void NewSubscriptionTieredWithMinimumValidationWorks() + public void NewAmountDiscountValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredWithMinimumPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewAmountDiscount() { - Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, - Name = "Annual fee", - TieredWithMinimumConfig = new() - { - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - HideZeroAmountTiers = true, - Prorate = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, + AmountDiscount = "amount_discount", + AppliesToAll = AppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewAmountDiscountFilterField.PriceID, + Operator = NewAmountDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = PriceType.Usage, }; value.Validate(); } [Fact] - public void NewSubscriptionGroupedTieredValidationWorks() + public void NewMinimumValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewMinimum() { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() - { - GroupingKey = "x", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - }, + AdjustmentType = NewMinimumAdjustmentType.Minimum, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + MinimumAmount = "minimum_amount", + AppliesToAll = NewMinimumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewMinimumFilterField.PriceID, + Operator = NewMinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMinimumPriceType.Usage, }; value.Validate(); } [Fact] - public void NewSubscriptionTieredPackageWithMinimumValidationWorks() + public void NewMaximumValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewMaximum() { - Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, - Name = "Annual fee", - TieredPackageWithMinimumConfig = new() - { - PackageSize = 0, - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - ], - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewMaximumAdjustmentType.Maximum, + MaximumAmount = "maximum_amount", + AppliesToAll = NewMaximumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewMaximumFilterField.PriceID, + Operator = NewMaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMaximumPriceType.Usage, }; value.Validate(); } [Fact] - public void NewSubscriptionPackageWithAllocationValidationWorks() + public void NewPercentageDiscountSerializationRoundtripWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewUsageDiscountSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionPackageWithAllocationPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewUsageDiscount() { - Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, - Name = "Annual fee", - PackageWithAllocationConfig = new() - { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, + UsageDiscount = 0, + AppliesToAll = NewUsageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewUsageDiscountFilterField.PriceID, + Operator = NewUsageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewUsageDiscountPriceType.Usage, }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewSubscriptionUnitWithPercentValidationWorks() + public void NewAmountDiscountSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithPercentPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewAmountDiscount() { - Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, - Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, + AmountDiscount = "amount_discount", + AppliesToAll = AppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewAmountDiscountFilterField.PriceID, + Operator = NewAmountDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = PriceType.Usage, }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewSubscriptionMatrixWithAllocationValidationWorks() + public void NewMinimumSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewMinimum() { - Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, + AdjustmentType = NewMinimumAdjustmentType.Minimum, ItemID = "item_id", - MatrixWithAllocationConfig = new() - { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = - [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + MinimumAmount = "minimum_amount", + AppliesToAll = NewMinimumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewMinimumFilterField.PriceID, + Operator = NewMinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMinimumPriceType.Usage, }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void TieredWithProrationValidationWorks() + public void NewMaximumSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewMaximum() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AdjustmentType = NewMaximumAdjustmentType.Maximum, + MaximumAmount = "maximum_amount", + AppliesToAll = NewMaximumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewMaximumFilterField.PriceID, + Operator = NewMaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMaximumPriceType.Usage, }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } +} +public class SubscriptionSchedulePlanChangeParamsReplacePriceTest : TestBase +{ [Fact] - public void NewSubscriptionUnitWithProrationValidationWorks() + public void FieldRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithProrationPrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + { + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, - Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + DurationUnit = CustomExpirationDurationUnit.Day, }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + Discounts = + [ + new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionGroupedAllocationValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedAllocationPrice() + ], + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 2, + MaximumAmount = "1.23", + MinimumAmount = "1.23", + Price = new Subscriptions::NewSubscriptionUnitPrice() { - Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14047,27 +11981,56 @@ public void NewSubscriptionGroupedAllocationValidationWorks() }, Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }; - value.Validate(); - } + }, + PriceID = "h74gfhdjvn7ujokd", + }; - [Fact] - public void NewSubscriptionBulkWithProrationValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionBulkWithProrationPrice() + string expectedReplacesPriceID = "replaces_price_id"; + NewAllocationPrice expectedAllocationPrice = new() + { + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", + }; + List expectedDiscounts = + [ + new() + { + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, + }, + ]; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 2; + string expectedMaximumAmount = "1.23"; + string expectedMinimumAmount = "1.23"; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice expectedPrice = + new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14099,92 +12062,74 @@ public void NewSubscriptionBulkWithProrationValidationWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + string expectedPriceID = "h74gfhdjvn7ujokd"; + + Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); + Assert.Equal(expectedAllocationPrice, model.AllocationPrice); + Assert.NotNull(model.Discounts); + Assert.Equal(expectedDiscounts.Count, model.Discounts.Count); + for (int i = 0; i < expectedDiscounts.Count; i++) + { + Assert.Equal(expectedDiscounts[i], model.Discounts[i]); + } + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedMaximumAmount, model.MaximumAmount); + Assert.Equal(expectedMinimumAmount, model.MinimumAmount); + Assert.Equal(expectedPrice, model.Price); + Assert.Equal(expectedPriceID, model.PriceID); } [Fact] - public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + { + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - Cadence = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + DurationUnit = CustomExpirationDurationUnit.Day, }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + Discounts = + [ + new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() + ], + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 2, + MaximumAmount = "1.23", + MinimumAmount = "1.23", + Price = new Subscriptions::NewSubscriptionUnitPrice() { - Cadence = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() - { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = - [ - new() - { - ScalingFactorValue = "scaling_factor", - ScalingValue = "scaling_value", - }, - ], - ScalingKey = "scaling_key", - UnitAmounts = - [ - new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, - ], - }, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14215,27 +12160,70 @@ public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() }, Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }; - value.Validate(); + }, + PriceID = "h74gfhdjvn7ujokd", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void GroupedWithMinMaxThresholdsValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + { + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + Discounts = + [ + new() + { + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, }, + ], + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 2, + MaximumAmount = "1.23", + MinimumAmount = "1.23", + Price = new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14266,34 +12254,64 @@ public void GroupedWithMinMaxThresholdsValidationWorks() }, Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }; - value.Validate(); - } + }, + PriceID = "h74gfhdjvn7ujokd", + }; - [Fact] - public void NewSubscriptionMatrixWithDisplayNameValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedReplacesPriceID = "replaces_price_id"; + NewAllocationPrice expectedAllocationPrice = new() + { + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { - Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, - ItemID = "item_id", - MatrixWithDisplayNameConfig = new() + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", + }; + List expectedDiscounts = + [ + new() + { + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, + }, + ]; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 2; + string expectedMaximumAmount = "1.23"; + string expectedMinimumAmount = "1.23"; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice expectedPrice = + new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14325,30 +12343,74 @@ public void NewSubscriptionMatrixWithDisplayNameValidationWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + string expectedPriceID = "h74gfhdjvn7ujokd"; + + Assert.Equal(expectedReplacesPriceID, deserialized.ReplacesPriceID); + Assert.Equal(expectedAllocationPrice, deserialized.AllocationPrice); + Assert.NotNull(deserialized.Discounts); + Assert.Equal(expectedDiscounts.Count, deserialized.Discounts.Count); + for (int i = 0; i < expectedDiscounts.Count; i++) + { + Assert.Equal(expectedDiscounts[i], deserialized.Discounts[i]); + } + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedMaximumAmount, deserialized.MaximumAmount); + Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); + Assert.Equal(expectedPrice, deserialized.Price); + Assert.Equal(expectedPriceID, deserialized.PriceID); } [Fact] - public void NewSubscriptionGroupedTieredPackageValidationWorks() + public void Validation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + { + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, - GroupedTieredPackageConfig = new() + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + Discounts = + [ + new() + { + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, }, + ], + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 2, + MaximumAmount = "1.23", + MinimumAmount = "1.23", + Price = new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14379,31 +12441,119 @@ public void NewSubscriptionGroupedTieredPackageValidationWorks() }, Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }; - value.Validate(); + }, + PriceID = "h74gfhdjvn7ujokd", + }; + + model.Validate(); } [Fact] - public void NewSubscriptionMaxGroupTieredPackageValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + { + ReplacesPriceID = "replaces_price_id", + }; + + Assert.Null(model.AllocationPrice); + Assert.False(model.RawData.ContainsKey("allocation_price")); + Assert.Null(model.Discounts); + Assert.False(model.RawData.ContainsKey("discounts")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.MaximumAmount); + Assert.False(model.RawData.ContainsKey("maximum_amount")); + Assert.Null(model.MinimumAmount); + Assert.False(model.RawData.ContainsKey("minimum_amount")); + Assert.Null(model.Price); + Assert.False(model.RawData.ContainsKey("price")); + Assert.Null(model.PriceID); + Assert.False(model.RawData.ContainsKey("price_id")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + { + ReplacesPriceID = "replaces_price_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + { + ReplacesPriceID = "replaces_price_id", + + AllocationPrice = null, + Discounts = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + MaximumAmount = null, + MinimumAmount = null, + Price = null, + PriceID = null, + }; + + Assert.Null(model.AllocationPrice); + Assert.True(model.RawData.ContainsKey("allocation_price")); + Assert.Null(model.Discounts); + Assert.True(model.RawData.ContainsKey("discounts")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.MaximumAmount); + Assert.True(model.RawData.ContainsKey("maximum_amount")); + Assert.Null(model.MinimumAmount); + Assert.True(model.RawData.ContainsKey("minimum_amount")); + Assert.Null(model.Price); + Assert.True(model.RawData.ContainsKey("price")); + Assert.Null(model.PriceID); + Assert.True(model.RawData.ContainsKey("price_id")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + { + ReplacesPriceID = "replaces_price_id", + + AllocationPrice = null, + Discounts = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + MaximumAmount = null, + MinimumAmount = null, + Price = null, + PriceID = null, + }; + + model.Validate(); + } +} + +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTest : TestBase +{ + [Fact] + public void NewSubscriptionUnitValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + new Subscriptions::NewSubscriptionUnitPrice() { - Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - MaxGroupTieredPackageConfig = new() - { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14439,32 +12589,27 @@ public void NewSubscriptionMaxGroupTieredPackageValidationWorks() } [Fact] - public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() + public void NewSubscriptionTieredValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + new Subscriptions::NewSubscriptionTieredPrice() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() + TieredConfig = new() { - FirstDimension = "first_dimension", - MatrixScalingFactors = + Tiers = [ new() { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, }, ], - UnitPrice = "unit_price", - Prorate = true, - SecondDimension = "second_dimension", + Prorated = true, }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14501,36 +12646,16 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() } [Fact] - public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() + public void NewSubscriptionBulkValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + new Subscriptions::NewSubscriptionBulkPrice() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + ModelType = Subscriptions::ModelType.Bulk, Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - SecondDimension = "second_dimension", - }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14566,28 +12691,23 @@ public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() } [Fact] - public void NewSubscriptionCumulativeGroupedBulkValidationWorks() + public void BulkWithFiltersValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters() { - Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() + BulkWithFiltersConfig = new() { - DimensionValues = + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], - Group = "group", }, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14624,22 +12744,16 @@ public void NewSubscriptionCumulativeGroupedBulkValidationWorks() } [Fact] - public void CumulativeGroupedAllocationValidationWorks() + public void NewSubscriptionPackageValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation() + new Subscriptions::NewSubscriptionPackagePrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14675,15 +12789,23 @@ public void CumulativeGroupedAllocationValidationWorks() } [Fact] - public void MinimumValidationWorks() + public void NewSubscriptionMatrixValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum() + new Subscriptions::NewSubscriptionMatrixPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, + ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14720,21 +12842,25 @@ public void MinimumValidationWorks() } [Fact] - public void NewSubscriptionMinimumCompositeValidationWorks() + public void NewSubscriptionThresholdTotalAmountValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMinimumCompositePrice() - { - Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, - ItemID = "item_id", - MinimumCompositeConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }, + new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + { + Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, + ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, + Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14770,16 +12896,24 @@ public void NewSubscriptionMinimumCompositeValidationWorks() } [Fact] - public void PercentValidationWorks() + public void NewSubscriptionTieredPackageValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercent() + new Subscriptions::NewSubscriptionTieredPackagePrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercentCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, Name = "Annual fee", - PercentConfig = new(0), + TieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14815,21 +12949,36 @@ public void PercentValidationWorks() } [Fact] - public void EventOutputValidationWorks() + public void NewSubscriptionTieredWithMinimumValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput() + new Subscriptions::NewSubscriptionTieredWithMinimumPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, Name = "Annual fee", + TieredWithMinimumConfig = new() + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + HideZeroAmountTiers = true, + Prorate = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14865,16 +13014,24 @@ public void EventOutputValidationWorks() } [Fact] - public void NewSubscriptionUnitSerializationRoundtripWorks() + public void NewSubscriptionGroupedTieredValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitPrice() + new Subscriptions::NewSubscriptionGroupedTieredPrice() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, + GroupedTieredConfig = new() + { + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14906,38 +13063,38 @@ public void NewSubscriptionUnitSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionTieredSerializationRoundtripWorks() + public void NewSubscriptionTieredPackageWithMinimumValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPrice() + new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, + ModelType = + Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, Name = "Annual fee", - TieredConfig = new() + TieredPackageWithMinimumConfig = new() { + PackageSize = 0, Tiers = [ new() { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", }, ], - Prorated = true, }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14970,27 +13127,26 @@ public void NewSubscriptionTieredSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionBulkSerializationRoundtripWorks() + public void NewSubscriptionPackageWithAllocationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionBulkPrice() + new Subscriptions::NewSubscriptionPackageWithAllocationPrice() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::ModelType.Bulk, + ModelType = + Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15022,35 +13178,21 @@ public void NewSubscriptionBulkSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void BulkWithFiltersSerializationRoundtripWorks() + public void NewSubscriptionUnitWithPercentValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters() + new Subscriptions::NewSubscriptionUnitWithPercentPrice() { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15082,27 +13224,30 @@ public void BulkWithFiltersSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionPackageSerializationRoundtripWorks() + public void NewSubscriptionMatrixWithAllocationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionPackagePrice() + new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() { - Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15134,35 +13279,22 @@ public void NewSubscriptionPackageSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionMatrixSerializationRoundtripWorks() + public void TieredWithProrationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration() { - Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", - MatrixConfig = new() - { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = - [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, - ], - }, - ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15194,36 +13326,21 @@ public void NewSubscriptionMatrixSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() + public void NewSubscriptionUnitWithProrationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + new Subscriptions::NewSubscriptionUnitWithProrationPrice() { - Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, Name = "Annual fee", - ThresholdTotalAmountConfig = new() - { - ConsumptionTable = - [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - ], - Prorate = true, - }, + UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15255,35 +13372,26 @@ public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionTieredPackageSerializationRoundtripWorks() + public void NewSubscriptionGroupedAllocationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackagePrice() + new Subscriptions::NewSubscriptionGroupedAllocationPrice() { - Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, - Name = "Annual fee", - TieredPackageConfig = new() + Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() { - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15315,47 +13423,26 @@ public void NewSubscriptionTieredPackageSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() + public void NewSubscriptionBulkWithProrationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredWithMinimumPrice() + new Subscriptions::NewSubscriptionBulkWithProrationPrice() { - Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, + Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, Name = "Annual fee", - TieredWithMinimumConfig = new() - { - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - HideZeroAmountTiers = true, - Prorate = true, - }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15387,34 +13474,26 @@ public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() + public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPrice() + new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + Cadence = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() { GroupingKey = "x", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], + Minimum = "minimum", + UnitRate = "unit_rate", }, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, + ModelType = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -15447,46 +13526,40 @@ public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() + public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, - Name = "Annual fee", - TieredPackageWithMinimumConfig = new() + Cadence = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, + GroupedWithMeteredMinimumConfig = new() { - PackageSize = 0, - Tiers = + GroupingKey = "x", + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = [ new() { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", }, ], + ScalingKey = "scaling_key", + UnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, + ], }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15518,33 +13591,26 @@ public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() + public void GroupedWithMinMaxThresholdsValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionPackageWithAllocationPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds() { - Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, - Name = "Annual fee", - PackageWithAllocationConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, + ItemID = "item_id", + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15576,28 +13642,33 @@ public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() + public void NewSubscriptionMatrixWithDisplayNameValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithPercentPrice() + new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() { - Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, ItemID = "item_id", + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, ModelType = - Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, + Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15629,36 +13700,29 @@ public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() + public void NewSubscriptionGroupedTieredPackageValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() + new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() { - Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, - ItemID = "item_id", - MatrixWithAllocationConfig = new() + Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, + GroupedTieredPackageConfig = new() { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = + GroupingKey = "x", + PackageSize = "package_size", + Tiers = [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], }, + ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, + Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -15689,31 +13753,32 @@ public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + ReferenceID = "reference_id", + }; + value.Validate(); } [Fact] - public void TieredWithProrationSerializationRoundtripWorks() + public void NewSubscriptionMaxGroupTieredPackageValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration() + new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, ItemID = "item_id", + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15745,28 +13810,37 @@ public void TieredWithProrationSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() + public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithProrationPrice() + new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() { - Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + Prorate = true, + SecondDimension = "second_dimension", + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15798,33 +13872,40 @@ public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() + public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedAllocationPrice() + new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() { - Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, Name = "Annual fee", + ScalableMatrixWithTieredPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + SecondDimension = "second_dimension", + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15856,32 +13937,32 @@ public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() + public void NewSubscriptionCumulativeGroupedBulkValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionBulkWithProrationPrice() + new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() { - BulkWithProrationConfig = new( + Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, + Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -15914,33 +13995,25 @@ public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks() + public void CumulativeGroupedAllocationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation() { Cadence = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", + UnitAmount = "unit_amount", }, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -15973,46 +14046,24 @@ public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void NewSubscriptionMinimumCompositeValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() + new Subscriptions::NewSubscriptionMinimumCompositePrice() { - Cadence = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() + Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, + ItemID = "item_id", + MinimumCompositeConfig = new() { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = - [ - new() - { - ScalingFactorValue = "scaling_factor", - ScalingValue = "scaling_value", - }, - ], - ScalingKey = "scaling_key", - UnitAmounts = - [ - new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, - ], + MinimumAmount = "minimum_amount", + Prorated = true, }, - ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -16045,33 +14096,20 @@ public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks( Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() + public void PercentValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercent() { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16103,39 +14141,24 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() + public void EventOutputValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput() { - Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, - ItemID = "item_id", - MatrixWithDisplayNameConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputCadence.Annual, + EventOutputConfig = new() { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -16168,37 +14191,20 @@ public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() + public void NewSubscriptionUnitSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() + new Subscriptions::NewSubscriptionUnitPrice() { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, - GroupedTieredPackageConfig = new() - { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], - }, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16241,26 +14247,28 @@ public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() + public void NewSubscriptionTieredSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + new Subscriptions::NewSubscriptionTieredPrice() { - Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, ItemID = "item_id", - MaxGroupTieredPackageConfig = new() + ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, + Name = "Annual fee", + TieredConfig = new() { - GroupingKey = "x", - PackageSize = "package_size", Tiers = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, ], + Prorated = true, }, - ModelType = - Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16303,33 +14311,16 @@ public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void NewSubscriptionBulkSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + new Subscriptions::NewSubscriptionBulkPrice() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + ModelType = Subscriptions::ModelType.Bulk, Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - UnitPrice = "unit_price", - Prorate = true, - SecondDimension = "second_dimension", - }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16372,36 +14363,24 @@ public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWo } [Fact] - public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void BulkWithFiltersSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, - Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() + BulkWithFiltersConfig = new() { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], Tiers = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], - SecondDimension = "second_dimension", }, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16444,29 +14423,16 @@ public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtrip } [Fact] - public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() + public void NewSubscriptionPackageSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + new Subscriptions::NewSubscriptionPackagePrice() { - Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() - { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", - }, + Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16509,21 +14475,23 @@ public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() } [Fact] - public void CumulativeGroupedAllocationSerializationRoundtripWorks() + public void NewSubscriptionMatrixSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation() + new Subscriptions::NewSubscriptionMatrixPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, + ItemID = "item_id", + MatrixConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], }, - ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -16567,16 +14535,25 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void MinimumSerializationRoundtripWorks() + public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum() + new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual, + Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = + Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, Name = "Annual fee", + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16619,21 +14596,24 @@ public void MinimumSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() + public void NewSubscriptionTieredPackageSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMinimumCompositePrice() + new Subscriptions::NewSubscriptionTieredPackagePrice() { - Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, ItemID = "item_id", - MinimumCompositeConfig = new() + ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, + Name = "Annual fee", + TieredPackageConfig = new() { - MinimumAmount = "minimum_amount", - Prorated = true, + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], }, - ModelType = - Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16676,16 +14656,36 @@ public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() } [Fact] - public void PercentSerializationRoundtripWorks() + public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercent() + new Subscriptions::NewSubscriptionTieredWithMinimumPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercentCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, Name = "Annual fee", - PercentConfig = new(0), + TieredWithMinimumConfig = new() + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + HideZeroAmountTiers = true, + Prorate = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16728,20 +14728,23 @@ public void PercentSerializationRoundtripWorks() } [Fact] - public void EventOutputSerializationRoundtripWorks() + public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput() + new Subscriptions::NewSubscriptionGroupedTieredPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, + GroupedTieredConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], }, ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -16783,29 +14786,37 @@ public void EventOutputSerializationRoundtripWorks() Assert.Equal(value, deserialized); } -} -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() { - BulkWithFiltersConfig = new() + Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + Name = "Annual fee", + TieredPackageWithMinimumConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + PackageSize = 0, Tiers = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, ], }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16837,103 +14848,33 @@ public void FieldRoundtrip_Works() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = - new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence - > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedBulkWithFiltersConfig, model.BulkWithFiltersConfig); - Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedItemID, model.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); - Assert.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); + Assert.Equal(value, deserialized); } [Fact] - public void SerializationRoundtrip_Works() + public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionPackageWithAllocationPrice() { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, + Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16965,36 +14906,28 @@ public void SerializationRoundtrip_Works() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( - json, + JsonSerializer.Deserialize( + element, ModelBase.SerializerOptions ); - Assert.Equal(model, deserialized); + Assert.Equal(value, deserialized); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionUnitWithPercentPrice() { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -17026,113 +14959,36 @@ public void FieldRoundtripThroughSerialization_Works() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); - Assert.NotNull(deserialized); - - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = - new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence - > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedBulkWithFiltersConfig, deserialized.BulkWithFiltersConfig); - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() { - BulkWithFiltersConfig = new() + Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, + ItemID = "item_id", + MatrixWithAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, ], }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -17165,679 +15021,983 @@ public void Validation_Works() Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - }; - - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.False(model.RawData.ContainsKey("reference_id")); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void TieredWithProrationSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration() { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; - - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.True(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.True(model.RawData.ContainsKey("reference_id")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; - - model.Validate(); - } -} - -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest - : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - List expectedFilters = - [ - new() { PropertyKey = "x", PropertyValue = "x" }, - ]; - List expectedTiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ]; - - Assert.Equal(expectedFilters.Count, model.Filters.Count); - for (int i = 0; i < expectedFilters.Count; i++) - { - Assert.Equal(expectedFilters[i], model.Filters[i]); - } - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( - json, + JsonSerializer.Deserialize( + element, ModelBase.SerializerOptions ); - Assert.Equal(model, deserialized); + Assert.Equal(value, deserialized); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionUnitWithProrationPrice() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, + Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); - Assert.NotNull(deserialized); - List expectedFilters = - [ - new() { PropertyKey = "x", PropertyValue = "x" }, - ]; - List expectedTiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ]; - - Assert.Equal(expectedFilters.Count, deserialized.Filters.Count); - for (int i = 0; i < expectedFilters.Count; i++) - { - Assert.Equal(expectedFilters[i], deserialized.Filters[i]); - } - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); - } + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedAllocationPrice() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - model.Validate(); + Assert.Equal(value, deserialized); } -} -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest - : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionBulkWithProrationPrice() { - PropertyKey = "x", - PropertyValue = "x", + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; - - Assert.Equal(expectedPropertyKey, model.PropertyKey); - Assert.Equal(expectedPropertyValue, model.PropertyValue); + Assert.Equal(value, deserialized); } [Fact] - public void SerializationRoundtrip_Works() + public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() { - PropertyKey = "x", - PropertyValue = "x", + Cadence = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( - json, + JsonSerializer.Deserialize( + element, ModelBase.SerializerOptions ); - Assert.Equal(model, deserialized); + Assert.Equal(value, deserialized); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() { - PropertyKey = "x", - PropertyValue = "x", + Cadence = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, + GroupedWithMeteredMinimumConfig = new() + { + GroupingKey = "x", + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = + [ + new() + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }, + ], + ScalingKey = "scaling_key", + UnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, + ], + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); - Assert.NotNull(deserialized); - - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; - - Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); - Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); - } - - [Fact] - public void Validation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - { - PropertyKey = "x", - PropertyValue = "x", - }; - - model.Validate(); - } -} - -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest - : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", - }; - - string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; - Assert.Equal(expectedUnitAmount, model.UnitAmount); - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(value, deserialized); } [Fact] - public void SerializationRoundtrip_Works() + public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds() { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( - json, + JsonSerializer.Deserialize( + element, ModelBase.SerializerOptions ); - Assert.Equal(model, deserialized); + Assert.Equal(value, deserialized); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, + ItemID = "item_id", + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); - Assert.NotNull(deserialized); - - string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; - - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - } - - [Fact] - public void Validation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - }; - Assert.Null(model.TierLowerBound); - Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() { - UnitAmount = "unit_amount", + Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, + GroupedTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - model.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() { - UnitAmount = "unit_amount", - - TierLowerBound = null, + Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, + ItemID = "item_id", + MaxGroupTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Assert.Null(model.TierLowerBound); - Assert.True(model.RawData.ContainsKey("tier_lower_bound")); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() { - UnitAmount = "unit_amount", - - TierLowerBound = null, - }; - - model.Validate(); - } -} - -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadenceTest - : TestBase -{ - [Theory] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.SemiAnnual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Monthly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Quarterly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.OneTime - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Custom - )] - public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence rawValue - ) - { - // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence - > value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence - > - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + Name = "Annual fee", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + Prorate = true, + SecondDimension = "second_dimension", + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); + Assert.Equal(value, deserialized); } - [Theory] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.SemiAnnual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Monthly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Quarterly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.OneTime - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Custom - )] - public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence rawValue - ) + [Fact] + public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtripWorks() { - // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence - > value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence - > - >(json, ModelBase.SerializerOptions); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + { + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + Name = "Annual fee", + ScalableMatrixWithTieredPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + SecondDimension = "second_dimension", + }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() { - var value = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence - > - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence - > - >(json, ModelBase.SerializerOptions); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + { + Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } -} -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfigTest - : TestBase -{ [Fact] - public void UnitValidationWorks() + public void CumulativeGroupedAllocationSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = - new SharedUnitConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void TieredValidationWorks() + public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = - new SharedTieredConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionMinimumCompositePrice() { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), + Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, + ItemID = "item_id", + MinimumCompositeConfig = new() + { + MinimumAmount = "minimum_amount", + Prorated = true, + }, + ModelType = + Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void UnitSerializationRoundtripWorks() + public void PercentSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = - new SharedUnitConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercent() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17846,26 +16006,55 @@ public void UnitSerializationRoundtripWorks() } [Fact] - public void TieredSerializationRoundtripWorks() + public void EventOutputSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = - new SharedTieredConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput() { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17874,21 +16063,27 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTest : TestBase +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -17921,16 +16116,24 @@ public void FieldRoundtrip_Works() ReferenceID = "reference_id", }; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = + new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = - new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -17939,7 +16142,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17963,11 +16166,11 @@ public void FieldRoundtrip_Works() Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; + Assert.Equal(expectedBulkWithFiltersConfig, model.BulkWithFiltersConfig); Assert.Equal(expectedCadence, model.Cadence); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -17994,15 +16197,21 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -18037,7 +16246,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18049,15 +16258,21 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -18092,22 +16307,30 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = + new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = - new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -18116,7 +16339,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18140,11 +16363,11 @@ public void FieldRoundtripThroughSerialization_Works() Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; + Assert.Equal(expectedBulkWithFiltersConfig, deserialized.BulkWithFiltersConfig); Assert.Equal(expectedCadence, deserialized.Cadence); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -18174,15 +16397,21 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -18222,15 +16451,21 @@ public void Validation_Works() public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; Assert.Null(model.BillableMetricID); @@ -18265,15 +16500,21 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; model.Validate(); @@ -18283,15 +16524,21 @@ public void OptionalNullablePropertiesUnsetValidation_Works() public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -18340,15 +16587,21 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -18369,151 +16622,164 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadenceTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase { - [Theory] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.SemiAnnual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Monthly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Quarterly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.OneTime - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Custom - )] - public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence rawValue - ) + [Fact] + public void FieldRoundtrip_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence - > value = rawValue; - value.Validate(); + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + List expectedFilters = + [ + new() { PropertyKey = "x", PropertyValue = "x" }, + ]; + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedFilters.Count, model.Filters.Count); + for (int i = 0; i < expectedFilters.Count; i++) + { + Assert.Equal(expectedFilters[i], model.Filters[i]); + } + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } } [Fact] - public void InvalidEnumValidationThrows_Works() + public void SerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence - > - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } - [Theory] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.SemiAnnual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Monthly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Quarterly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.OneTime - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Custom - )] - public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence rawValue - ) + [Fact] + public void FieldRoundtripThroughSerialization_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence - > value = rawValue; + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence - > - >(json, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); - Assert.Equal(value, deserialized); + List expectedFilters = + [ + new() { PropertyKey = "x", PropertyValue = "x" }, + ]; + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ]; + + Assert.Equal(expectedFilters.Count, deserialized.Filters.Count); + for (int i = 0; i < expectedFilters.Count; i++) + { + Assert.Equal(expectedFilters[i], deserialized.Filters[i]); + } + Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + } } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void Validation_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence - > - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence - > - >(json, ModelBase.SerializerOptions); + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; - Assert.Equal(value, deserialized); + model.Validate(); } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + PropertyKey = "x", + PropertyValue = "x", }; - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; + string expectedPropertyKey = "x"; + string expectedPropertyValue = "x"; - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } + Assert.Equal(expectedPropertyKey, model.PropertyKey); + Assert.Equal(expectedPropertyValue, model.PropertyValue); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + PropertyKey = "x", + PropertyValue = "x", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18525,77 +16791,74 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + PropertyKey = "x", + PropertyValue = "x", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; + string expectedPropertyKey = "x"; + string expectedPropertyValue = "x"; - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); - } + Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); + Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); } [Fact] public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + PropertyKey = "x", + PropertyValue = "x", }; model.Validate(); } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTierTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; - string expectedTierLowerBound = "tier_lower_bound"; string expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18607,48 +16870,211 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + string expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + } + + [Fact] + public void Validation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + }; + + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, + }; + + Assert.Null(model.TierLowerBound); + Assert.True(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, + }; + + model.Validate(); + } +} + +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadenceTest + : TestBase +{ + [Theory] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.SemiAnnual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Monthly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Quarterly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.OneTime + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Custom + )] + public void Validation_Works( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence + > value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.SemiAnnual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Monthly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Quarterly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.OneTime + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Custom + )] + public void SerializationRoundtrip_Works( + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence + > value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence + > + >(json, ModelBase.SerializerOptions); - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void InvalidEnumSerializationRoundtrip_Works() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence + > + >(json, ModelBase.SerializerOptions); - model.Validate(); + Assert.Equal(value, deserialized); } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18660,7 +17086,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -18681,7 +17107,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18689,7 +17115,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18700,7 +17126,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -18717,7 +17143,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18726,26 +17152,21 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsTest - : TestBase +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -18780,22 +17201,14 @@ public void FieldRoundtrip_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = - new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -18804,7 +17217,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18829,13 +17242,10 @@ public void FieldRoundtrip_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal( - expectedGroupedWithMinMaxThresholdsConfig, - model.GroupedWithMinMaxThresholdsConfig - ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -18862,19 +17272,15 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -18909,7 +17315,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18921,19 +17327,15 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -18968,7 +17370,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18976,22 +17378,14 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = - new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -19000,7 +17394,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19025,13 +17419,10 @@ public void FieldRoundtripThroughSerialization_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal( - expectedGroupedWithMinMaxThresholdsConfig, - deserialized.GroupedWithMinMaxThresholdsConfig - ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -19061,19 +17452,15 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -19113,19 +17500,15 @@ public void Validation_Works() public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; Assert.Null(model.BillableMetricID); @@ -19160,19 +17543,15 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; model.Validate(); @@ -19182,19 +17561,15 @@ public void OptionalNullablePropertiesUnsetValidation_Works() public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -19243,19 +17618,15 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -19276,36 +17647,36 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadenceTest : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > value = rawValue; value.Validate(); } @@ -19316,7 +17687,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -19326,38 +17697,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > >(json, ModelBase.SerializerOptions); @@ -19370,14 +17741,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > >(json, ModelBase.SerializerOptions); @@ -19385,47 +17756,42 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -19437,56 +17803,130 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); - Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); - Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); + Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + } } [Fact] public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; model.Validate(); } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTierTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } +} + +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19498,7 +17938,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -19519,7 +17959,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19527,7 +17967,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19538,7 +17978,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -19555,7 +17995,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19564,23 +18004,23 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -19618,20 +18058,20 @@ public void FieldRoundtrip_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" + "grouped_with_min_max_thresholds" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -19642,7 +18082,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19668,8 +18108,8 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedCadence, model.Cadence); Assert.Equal( - expectedCumulativeGroupedAllocationConfig, - model.CumulativeGroupedAllocationConfig + expectedGroupedWithMinMaxThresholdsConfig, + model.GroupedWithMinMaxThresholdsConfig ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); @@ -19700,16 +18140,16 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -19747,7 +18187,7 @@ public void SerializationRoundtrip_Works() string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -19759,16 +18199,16 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -19806,7 +18246,7 @@ public void FieldRoundtripThroughSerialization_Works() string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19814,20 +18254,20 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" + "grouped_with_min_max_thresholds" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -19838,7 +18278,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19864,8 +18304,8 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedCadence, deserialized.Cadence); Assert.Equal( - expectedCumulativeGroupedAllocationConfig, - deserialized.CumulativeGroupedAllocationConfig + expectedGroupedWithMinMaxThresholdsConfig, + deserialized.GroupedWithMinMaxThresholdsConfig ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); @@ -19899,16 +18339,16 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -19951,16 +18391,16 @@ public void Validation_Works() public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -19998,16 +18438,16 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -20020,16 +18460,16 @@ public void OptionalNullablePropertiesUnsetValidation_Works() public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -20081,16 +18521,16 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -20114,36 +18554,36 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadenceTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > value = rawValue; value.Validate(); } @@ -20154,7 +18594,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -20164,38 +18604,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > >(json, ModelBase.SerializerOptions); @@ -20208,14 +18648,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > >(json, ModelBase.SerializerOptions); @@ -20223,47 +18663,47 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedMaximumCharge, model.MaximumCharge); + Assert.Equal(expectedMinimumCharge, model.MinimumCharge); + Assert.Equal(expectedPerUnitRate, model.PerUnitRate); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -20275,56 +18715,56 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); + Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); + Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); } [Fact] public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; model.Validate(); } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20336,7 +18776,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -20357,7 +18797,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20365,7 +18805,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -20376,7 +18816,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -20393,7 +18833,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -20402,59 +18842,75 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumTest : TestBase +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig expectedMinimumConfig = - new() { MinimumAmount = "minimum_amount", Prorated = true }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -20464,7 +18920,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20489,8 +18945,11 @@ public void FieldRoundtrip_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + model.CumulativeGroupedAllocationConfig + ); Assert.Equal(expectedItemID, model.ItemID); - Assert.Equal(expectedMinimumConfig, model.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -20518,48 +18977,55 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -20570,48 +19036,55 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -20619,13 +19092,21 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig expectedMinimumConfig = - new() { MinimumAmount = "minimum_amount", Prorated = true }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -20635,7 +19116,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20660,8 +19141,11 @@ public void FieldRoundtripThroughSerialization_Works() string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal( + expectedCumulativeGroupedAllocationConfig, + deserialized.CumulativeGroupedAllocationConfig + ); Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.Equal(expectedMinimumConfig, deserialized.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -20692,44 +19176,51 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; model.Validate(); } @@ -20737,14 +19228,21 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - }; + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + }; Assert.Null(model.BillableMetricID); Assert.False(model.RawData.ContainsKey("billable_metric_id")); @@ -20777,14 +19275,21 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - }; + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + }; model.Validate(); } @@ -20792,28 +19297,35 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + Metadata = null, + ReferenceID = null, + }; Assert.Null(model.BillableMetricID); Assert.True(model.RawData.ContainsKey("billable_metric_id")); @@ -20846,62 +19358,70 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + Metadata = null, + ReferenceID = null, + }; model.Validate(); } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadenceTest : TestBase +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadenceTest + : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > value = rawValue; value.Validate(); } @@ -20912,7 +19432,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -20922,38 +19442,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > >(json, ModelBase.SerializerOptions); @@ -20966,14 +19486,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > >(json, ModelBase.SerializerOptions); @@ -20981,39 +19501,47 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfigTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, model.GroupAllocation); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -21025,104 +19553,56 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; model.Validate(); } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -21134,7 +19614,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -21155,7 +19635,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -21163,7 +19643,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -21174,7 +19654,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -21191,7 +19671,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionTriggerPhaseParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionTriggerPhaseParamsTest.cs index 9267a7f8..6bfa2b26 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionTriggerPhaseParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionTriggerPhaseParamsTest.cs @@ -64,4 +64,19 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionTriggerPhaseParams + { + SubscriptionID = "subscription_id", + AllowInvoiceCreditOrVoid = true, + EffectiveDate = "2019-12-27", + }; + + SubscriptionTriggerPhaseParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionUnscheduleCancellationParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionUnscheduleCancellationParamsTest.cs index f7fe2dcd..9ce3060d 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionUnscheduleCancellationParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionUnscheduleCancellationParamsTest.cs @@ -35,4 +35,17 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionUnscheduleCancellationParams + { + SubscriptionID = "subscription_id", + }; + + SubscriptionUnscheduleCancellationParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionUnscheduleFixedFeeQuantityUpdatesParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionUnscheduleFixedFeeQuantityUpdatesParamsTest.cs index c8e5fa8a..7da9e7a0 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionUnscheduleFixedFeeQuantityUpdatesParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionUnscheduleFixedFeeQuantityUpdatesParamsTest.cs @@ -39,4 +39,18 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionUnscheduleFixedFeeQuantityUpdatesParams + { + SubscriptionID = "subscription_id", + PriceID = "price_id", + }; + + SubscriptionUnscheduleFixedFeeQuantityUpdatesParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionUnschedulePendingPlanChangesParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionUnschedulePendingPlanChangesParamsTest.cs index 68222404..b8737d0a 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionUnschedulePendingPlanChangesParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionUnschedulePendingPlanChangesParamsTest.cs @@ -35,4 +35,17 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionUnschedulePendingPlanChangesParams + { + SubscriptionID = "subscription_id", + }; + + SubscriptionUnschedulePendingPlanChangesParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionUpdateFixedFeeQuantityParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionUpdateFixedFeeQuantityParamsTest.cs index e06decc4..b5135530 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionUpdateFixedFeeQuantityParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionUpdateFixedFeeQuantityParamsTest.cs @@ -128,6 +128,24 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionUpdateFixedFeeQuantityParams + { + SubscriptionID = "subscription_id", + PriceID = "price_id", + Quantity = 0, + AllowInvoiceCreditOrVoid = true, + ChangeOption = SubscriptionUpdateFixedFeeQuantityParamsChangeOption.Immediate, + EffectiveDate = "2022-12-21", + }; + + SubscriptionUpdateFixedFeeQuantityParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class SubscriptionUpdateFixedFeeQuantityParamsChangeOptionTest : TestBase diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionUpdateParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionUpdateParamsTest.cs index 663a07f5..db9d0feb 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionUpdateParamsTest.cs @@ -93,4 +93,22 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/subscriptions/subscription_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionUpdateParams + { + SubscriptionID = "subscription_id", + AutoCollection = true, + DefaultInvoiceMemo = "default_invoice_memo", + InvoicingThreshold = "10.00", + Metadata = new Dictionary() { { "foo", "string" } }, + NetTerms = 0, + }; + + SubscriptionUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Subscriptions/SubscriptionUpdateTrialParamsTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionUpdateTrialParamsTest.cs index 13aa6876..177b748b 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionUpdateTrialParamsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionUpdateTrialParamsTest.cs @@ -72,6 +72,21 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionUpdateTrialParams + { + SubscriptionID = "subscription_id", + TrialEndDate = DateTimeOffset.Parse("2017-07-21T17:32:28Z"), + Shift = true, + }; + + SubscriptionUpdateTrialParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class TrialEndDateTest : TestBase diff --git a/src/Orb/Core/ApiEnum.cs b/src/Orb/Core/ApiEnum.cs index 32b85f26..0d74d005 100644 --- a/src/Orb/Core/ApiEnum.cs +++ b/src/Orb/Core/ApiEnum.cs @@ -94,6 +94,9 @@ public virtual bool Equals(ApiEnum? other) return other != null && JsonElement.DeepEquals(this.Json, other.Json); } + public override string ToString() => + JsonSerializer.Serialize(this.Json, ModelBase.ToStringSerializerOptions); + public override int GetHashCode() { return 0; diff --git a/src/Orb/Core/ModelBase.cs b/src/Orb/Core/ModelBase.cs index 165003cf..cf069d55 100644 --- a/src/Orb/Core/ModelBase.cs +++ b/src/Orb/Core/ModelBase.cs @@ -398,11 +398,6 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -435,7 +430,6 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -448,14 +442,12 @@ protected ModelBase(ModelBase modelBase) string, Beta::ReplacePricePriceCumulativeGroupedAllocationCadence >(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -471,7 +463,6 @@ protected ModelBase(ModelBase modelBase) string, ExternalPlanID::ReplacePricePriceCumulativeGroupedAllocationCadence >(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -588,7 +579,6 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -599,7 +589,6 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -620,13 +609,11 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter< @@ -641,10 +628,6 @@ protected ModelBase(ModelBase modelBase) string, Prices::PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence >(), - new ApiEnumConverter< - string, - Prices::PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence - >(), new ApiEnumConverter< string, Prices::PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentCadence @@ -825,7 +808,6 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -842,7 +824,6 @@ protected ModelBase(ModelBase modelBase) string, Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence >(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -859,7 +840,6 @@ protected ModelBase(ModelBase modelBase) string, Subscriptions::PriceModelCumulativeGroupedAllocationCadence >(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -883,10 +863,6 @@ protected ModelBase(ModelBase modelBase) string, Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence >(), - new ApiEnumConverter< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence - >(), new ApiEnumConverter< string, Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence @@ -912,10 +888,6 @@ protected ModelBase(ModelBase modelBase) string, Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence >(), - new ApiEnumConverter< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence - >(), new ApiEnumConverter< string, Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercentCadence diff --git a/src/Orb/Models/Alerts/AlertCreateForCustomerParams.cs b/src/Orb/Models/Alerts/AlertCreateForCustomerParams.cs index 6fb70fe8..6f6dcb70 100644 --- a/src/Orb/Models/Alerts/AlertCreateForCustomerParams.cs +++ b/src/Orb/Models/Alerts/AlertCreateForCustomerParams.cs @@ -19,8 +19,12 @@ namespace Orb.Models.Alerts; /// maximum of one of each type of alert per [credit balance currency](/product-catalog/prepurchase). /// `credit_balance_dropped` alerts require a list of thresholds to be provided while /// `credit_balance_depleted` and `credit_balance_recovered` alerts do not require thresholds. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class AlertCreateForCustomerParams : ParamsBase +public record class AlertCreateForCustomerParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -79,6 +83,8 @@ public IReadOnlyList? Thresholds public AlertCreateForCustomerParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AlertCreateForCustomerParams(AlertCreateForCustomerParams alertCreateForCustomerParams) : base(alertCreateForCustomerParams) { @@ -86,6 +92,7 @@ public AlertCreateForCustomerParams(AlertCreateForCustomerParams alertCreateForC this._rawBodyData = new(alertCreateForCustomerParams._rawBodyData); } +#pragma warning restore CS8618 public AlertCreateForCustomerParams( IReadOnlyDictionary rawHeaderData, @@ -126,6 +133,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["CustomerID"] = this.CustomerID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(AlertCreateForCustomerParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -154,12 +185,17 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// /// The type of alert to create. This must be a valid alert type. /// -[JsonConverter(typeof(global::Orb.Models.Alerts.TypeConverter))] +[JsonConverter(typeof(TypeConverter))] public enum Type { CreditBalanceDepleted, diff --git a/src/Orb/Models/Alerts/AlertCreateForExternalCustomerParams.cs b/src/Orb/Models/Alerts/AlertCreateForExternalCustomerParams.cs index 3e5cc7a0..69de9571 100644 --- a/src/Orb/Models/Alerts/AlertCreateForExternalCustomerParams.cs +++ b/src/Orb/Models/Alerts/AlertCreateForExternalCustomerParams.cs @@ -19,8 +19,12 @@ namespace Orb.Models.Alerts; /// maximum of one of each type of alert per [credit balance currency](/product-catalog/prepurchase). /// `credit_balance_dropped` alerts require a list of thresholds to be provided while /// `credit_balance_depleted` and `credit_balance_recovered` alerts do not require thresholds. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class AlertCreateForExternalCustomerParams : ParamsBase +public record class AlertCreateForExternalCustomerParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -79,6 +83,8 @@ public IReadOnlyList? Thresholds public AlertCreateForExternalCustomerParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AlertCreateForExternalCustomerParams( AlertCreateForExternalCustomerParams alertCreateForExternalCustomerParams ) @@ -88,6 +94,7 @@ AlertCreateForExternalCustomerParams alertCreateForExternalCustomerParams this._rawBodyData = new(alertCreateForExternalCustomerParams._rawBodyData); } +#pragma warning restore CS8618 public AlertCreateForExternalCustomerParams( IReadOnlyDictionary rawHeaderData, @@ -128,6 +135,33 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ExternalCustomerID"] = this.ExternalCustomerID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(AlertCreateForExternalCustomerParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalCustomerID?.Equals(other.ExternalCustomerID) + ?? other.ExternalCustomerID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -156,6 +190,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// diff --git a/src/Orb/Models/Alerts/AlertCreateForSubscriptionParams.cs b/src/Orb/Models/Alerts/AlertCreateForSubscriptionParams.cs index 14c41d7d..6fc4351e 100644 --- a/src/Orb/Models/Alerts/AlertCreateForSubscriptionParams.cs +++ b/src/Orb/Models/Alerts/AlertCreateForSubscriptionParams.cs @@ -24,8 +24,12 @@ namespace Orb.Models.Alerts; /// `cost_exceeded` alert and one `usage_exceeded` alert per metric that is a part /// of the subscription. Alerts are triggered based on usage or cost conditions met /// during the current billing cycle. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class AlertCreateForSubscriptionParams : ParamsBase +public record class AlertCreateForSubscriptionParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -84,6 +88,8 @@ public string? MetricID public AlertCreateForSubscriptionParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AlertCreateForSubscriptionParams( AlertCreateForSubscriptionParams alertCreateForSubscriptionParams ) @@ -93,6 +99,7 @@ AlertCreateForSubscriptionParams alertCreateForSubscriptionParams this._rawBodyData = new(alertCreateForSubscriptionParams._rawBodyData); } +#pragma warning restore CS8618 public AlertCreateForSubscriptionParams( IReadOnlyDictionary rawHeaderData, @@ -133,6 +140,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["SubscriptionID"] = this.SubscriptionID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(AlertCreateForSubscriptionParams? other) + { + if (other == null) + { + return false; + } + return (this.SubscriptionID?.Equals(other.SubscriptionID) ?? other.SubscriptionID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -161,6 +192,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// diff --git a/src/Orb/Models/Alerts/AlertDisableParams.cs b/src/Orb/Models/Alerts/AlertDisableParams.cs index 37a6fc2a..b1148f38 100644 --- a/src/Orb/Models/Alerts/AlertDisableParams.cs +++ b/src/Orb/Models/Alerts/AlertDisableParams.cs @@ -12,8 +12,12 @@ namespace Orb.Models.Alerts; /// This endpoint allows you to disable an alert. To disable a plan-level alert for /// a specific subscription, you must include the `subscription_id`. The `subscription_id` /// is not required for customer or subscription level alerts. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class AlertDisableParams : ParamsBase +public record class AlertDisableParams : ParamsBase { public string? AlertConfigurationID { get; init; } @@ -32,11 +36,14 @@ public string? SubscriptionID public AlertDisableParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AlertDisableParams(AlertDisableParams alertDisableParams) : base(alertDisableParams) { this.AlertConfigurationID = alertDisableParams.AlertConfigurationID; } +#pragma warning restore CS8618 public AlertDisableParams( IReadOnlyDictionary rawHeaderData, @@ -71,6 +78,31 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["AlertConfigurationID"] = this.AlertConfigurationID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(AlertDisableParams? other) + { + if (other == null) + { + return false; + } + return ( + this.AlertConfigurationID?.Equals(other.AlertConfigurationID) + ?? other.AlertConfigurationID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -90,4 +122,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Alerts/AlertEnableParams.cs b/src/Orb/Models/Alerts/AlertEnableParams.cs index 530e5531..50b9b152 100644 --- a/src/Orb/Models/Alerts/AlertEnableParams.cs +++ b/src/Orb/Models/Alerts/AlertEnableParams.cs @@ -12,8 +12,12 @@ namespace Orb.Models.Alerts; /// This endpoint allows you to enable an alert. To enable a plan-level alert for /// a specific subscription, you must include the `subscription_id`. The `subscription_id` /// is not required for customer or subscription level alerts. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class AlertEnableParams : ParamsBase +public record class AlertEnableParams : ParamsBase { public string? AlertConfigurationID { get; init; } @@ -32,11 +36,14 @@ public string? SubscriptionID public AlertEnableParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AlertEnableParams(AlertEnableParams alertEnableParams) : base(alertEnableParams) { this.AlertConfigurationID = alertEnableParams.AlertConfigurationID; } +#pragma warning restore CS8618 public AlertEnableParams( IReadOnlyDictionary rawHeaderData, @@ -71,6 +78,31 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["AlertConfigurationID"] = this.AlertConfigurationID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(AlertEnableParams? other) + { + if (other == null) + { + return false; + } + return ( + this.AlertConfigurationID?.Equals(other.AlertConfigurationID) + ?? other.AlertConfigurationID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -90,4 +122,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Alerts/AlertListParams.cs b/src/Orb/Models/Alerts/AlertListParams.cs index 7bb864ca..a6d9234b 100644 --- a/src/Orb/Models/Alerts/AlertListParams.cs +++ b/src/Orb/Models/Alerts/AlertListParams.cs @@ -19,8 +19,12 @@ namespace Orb.Models.Alerts; /// /// The list of alerts is ordered starting from the most recently created alert. /// This endpoint follows Orb's [standardized pagination format](/api-reference/pagination). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class AlertListParams : ParamsBase +public record class AlertListParams : ParamsBase { public DateTimeOffset? CreatedAtGt { @@ -138,8 +142,11 @@ public string? SubscriptionID public AlertListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AlertListParams(AlertListParams alertListParams) : base(alertListParams) { } +#pragma warning restore CS8618 public AlertListParams( IReadOnlyDictionary rawHeaderData, @@ -174,6 +181,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(AlertListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/alerts") @@ -190,4 +217,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Alerts/AlertRetrieveParams.cs b/src/Orb/Models/Alerts/AlertRetrieveParams.cs index f966c61b..a23480b0 100644 --- a/src/Orb/Models/Alerts/AlertRetrieveParams.cs +++ b/src/Orb/Models/Alerts/AlertRetrieveParams.cs @@ -10,18 +10,25 @@ namespace Orb.Models.Alerts; /// /// This endpoint retrieves an alert by its ID. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class AlertRetrieveParams : ParamsBase +public record class AlertRetrieveParams : ParamsBase { public string? AlertID { get; init; } public AlertRetrieveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AlertRetrieveParams(AlertRetrieveParams alertRetrieveParams) : base(alertRetrieveParams) { this.AlertID = alertRetrieveParams.AlertID; } +#pragma warning restore CS8618 public AlertRetrieveParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["AlertID"] = this.AlertID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(AlertRetrieveParams? other) + { + if (other == null) + { + return false; + } + return (this.AlertID?.Equals(other.AlertID) ?? other.AlertID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -74,4 +103,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Alerts/AlertUpdateParams.cs b/src/Orb/Models/Alerts/AlertUpdateParams.cs index 4ef7d2ad..6e1e556c 100644 --- a/src/Orb/Models/Alerts/AlertUpdateParams.cs +++ b/src/Orb/Models/Alerts/AlertUpdateParams.cs @@ -12,8 +12,12 @@ namespace Orb.Models.Alerts; /// /// This endpoint updates the thresholds of an alert. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class AlertUpdateParams : ParamsBase +public record class AlertUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -44,6 +48,8 @@ public required IReadOnlyList Thresholds public AlertUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AlertUpdateParams(AlertUpdateParams alertUpdateParams) : base(alertUpdateParams) { @@ -51,6 +57,7 @@ public AlertUpdateParams(AlertUpdateParams alertUpdateParams) this._rawBodyData = new(alertUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public AlertUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -91,6 +98,33 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["AlertConfigurationID"] = this.AlertConfigurationID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(AlertUpdateParams? other) + { + if (other == null) + { + return false; + } + return ( + this.AlertConfigurationID?.Equals(other.AlertConfigurationID) + ?? other.AlertConfigurationID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -119,4 +153,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs b/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs index 147e0d65..8f63e667 100644 --- a/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs +++ b/src/Orb/Models/Beta/BetaCreatePlanVersionParams.cs @@ -14,8 +14,12 @@ namespace Orb.Models.Beta; /// /// This endpoint allows the creation of a new plan version for an existing plan. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BetaCreatePlanVersionParams : ParamsBase +public record class BetaCreatePlanVersionParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -177,6 +181,8 @@ public bool? SetAsDefault public BetaCreatePlanVersionParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BetaCreatePlanVersionParams(BetaCreatePlanVersionParams betaCreatePlanVersionParams) : base(betaCreatePlanVersionParams) { @@ -184,6 +190,7 @@ public BetaCreatePlanVersionParams(BetaCreatePlanVersionParams betaCreatePlanVer this._rawBodyData = new(betaCreatePlanVersionParams._rawBodyData); } +#pragma warning restore CS8618 public BetaCreatePlanVersionParams( IReadOnlyDictionary rawHeaderData, @@ -224,6 +231,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["PlanID"] = this.PlanID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BetaCreatePlanVersionParams? other) + { + if (other == null) + { + return false; + } + return (this.PlanID?.Equals(other.PlanID) ?? other.PlanID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -252,6 +283,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(JsonModelConverter))] @@ -260,12 +296,12 @@ public sealed record class AddAdjustment : JsonModel /// /// The definition of a new adjustment to create and add to the plan. /// - public required global::Orb.Models.Beta.Adjustment Adjustment + public required Adjustment Adjustment { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment"); + return this._rawData.GetNotNullClass("adjustment"); } init { this._rawData.Set("adjustment", value); } } @@ -315,7 +351,7 @@ public static AddAdjustment FromRawUnchecked(IReadOnlyDictionary r /// /// The definition of a new adjustment to create and add to the plan. /// -[JsonConverter(typeof(global::Orb.Models.Beta.AdjustmentConverter))] +[JsonConverter(typeof(AdjustmentConverter))] public record class Adjustment : ModelBase { public object? Value { get; } = null; @@ -614,21 +650,15 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Beta.Adjustment( - NewPercentageDiscount value - ) => new(value); + public static implicit operator Adjustment(NewPercentageDiscount value) => new(value); - public static implicit operator global::Orb.Models.Beta.Adjustment(NewUsageDiscount value) => - new(value); + public static implicit operator Adjustment(NewUsageDiscount value) => new(value); - public static implicit operator global::Orb.Models.Beta.Adjustment(NewAmountDiscount value) => - new(value); + public static implicit operator Adjustment(NewAmountDiscount value) => new(value); - public static implicit operator global::Orb.Models.Beta.Adjustment(NewMinimum value) => - new(value); + public static implicit operator Adjustment(NewMinimum value) => new(value); - public static implicit operator global::Orb.Models.Beta.Adjustment(NewMaximum value) => - new(value); + public static implicit operator Adjustment(NewMaximum value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -655,7 +685,7 @@ public override void Validate() ); } - public virtual bool Equals(global::Orb.Models.Beta.Adjustment? other) + public virtual bool Equals(Adjustment? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -669,9 +699,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class AdjustmentConverter : JsonConverter +sealed class AdjustmentConverter : JsonConverter { - public override global::Orb.Models.Beta.Adjustment? Read( + public override Adjustment? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -796,14 +826,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.Adjustment(element); + return new Adjustment(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.Adjustment value, + Adjustment value, JsonSerializerOptions options ) { @@ -843,12 +873,12 @@ public long? PlanPhaseOrder /// /// New plan price request body params. /// - public global::Orb.Models.Beta.Price? Price + public Price? Price { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("price"); + return this._rawData.GetNullableClass("price"); } init { this._rawData.Set("price", value); } } @@ -896,7 +926,7 @@ public AddPrice FromRawUnchecked(IReadOnlyDictionary rawDat /// /// New plan price request body params. /// -[JsonConverter(typeof(global::Orb.Models.Beta.PriceConverter))] +[JsonConverter(typeof(PriceConverter))] public record class Price : ModelBase { public object? Value { get; } = null; @@ -947,7 +977,6 @@ public string ItemID newPlanScalableMatrixWithTieredPricing: (x) => x.ItemID, newPlanCumulativeGroupedBulk: (x) => x.ItemID, cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, newPlanMinimumComposite: (x) => x.ItemID, percent: (x) => x.ItemID, eventOutput: (x) => x.ItemID @@ -988,7 +1017,6 @@ public string Name newPlanScalableMatrixWithTieredPricing: (x) => x.Name, newPlanCumulativeGroupedBulk: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, newPlanMinimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name @@ -1029,7 +1057,6 @@ public string? BillableMetricID newPlanScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, newPlanCumulativeGroupedBulk: (x) => x.BillableMetricID, cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, newPlanMinimumComposite: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID @@ -1070,7 +1097,6 @@ public bool? BilledInAdvance newPlanScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, newPlanCumulativeGroupedBulk: (x) => x.BilledInAdvance, cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, newPlanMinimumComposite: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance @@ -1111,7 +1137,6 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newPlanScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, newPlanCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, newPlanMinimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration @@ -1152,7 +1177,6 @@ public double? ConversionRate newPlanScalableMatrixWithTieredPricing: (x) => x.ConversionRate, newPlanCumulativeGroupedBulk: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, newPlanMinimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate @@ -1193,7 +1217,6 @@ public string? Currency newPlanScalableMatrixWithTieredPricing: (x) => x.Currency, newPlanCumulativeGroupedBulk: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, newPlanMinimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency @@ -1234,7 +1257,6 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration newPlanScalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, newPlanCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, newPlanMinimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration @@ -1275,7 +1297,6 @@ public string? ExternalPriceID newPlanScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, newPlanCumulativeGroupedBulk: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, newPlanMinimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID @@ -1316,7 +1337,6 @@ public double? FixedPriceQuantity newPlanScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, newPlanCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, newPlanMinimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity @@ -1357,7 +1377,6 @@ public string? InvoiceGroupingKey newPlanScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, newPlanCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, newPlanMinimumComposite: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey @@ -1398,7 +1417,6 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration newPlanScalableMatrixWithTieredPricing: (x) => x.InvoicingCycleConfiguration, newPlanCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, newPlanMinimumComposite: (x) => x.InvoicingCycleConfiguration, percent: (x) => x.InvoicingCycleConfiguration, eventOutput: (x) => x.InvoicingCycleConfiguration @@ -1439,7 +1457,6 @@ public string? ReferenceID newPlanScalableMatrixWithTieredPricing: (x) => x.ReferenceID, newPlanCumulativeGroupedBulk: (x) => x.ReferenceID, cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, newPlanMinimumComposite: (x) => x.ReferenceID, percent: (x) => x.ReferenceID, eventOutput: (x) => x.ReferenceID @@ -1465,7 +1482,7 @@ public Price(NewPlanBulkPrice value, JsonElement? element = null) this._element = element; } - public Price(global::Orb.Models.Beta.BulkWithFilters value, JsonElement? element = null) + public Price(BulkWithFilters value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1531,7 +1548,7 @@ public Price(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null this._element = element; } - public Price(global::Orb.Models.Beta.TieredWithProration value, JsonElement? element = null) + public Price(TieredWithProration value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1567,10 +1584,7 @@ public Price(NewPlanGroupedWithMeteredMinimumPrice value, JsonElement? element = this._element = element; } - public Price( - global::Orb.Models.Beta.GroupedWithMinMaxThresholds value, - JsonElement? element = null - ) + public Price(GroupedWithMinMaxThresholds value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1612,16 +1626,7 @@ public Price(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = nul this._element = element; } - public Price( - global::Orb.Models.Beta.CumulativeGroupedAllocation value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public Price(global::Orb.Models.Beta.Minimum value, JsonElement? element = null) + public Price(CumulativeGroupedAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1633,13 +1638,13 @@ public Price(NewPlanMinimumCompositePrice value, JsonElement? element = null) this._element = element; } - public Price(global::Orb.Models.Beta.Percent value, JsonElement? element = null) + public Price(Percent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(global::Orb.Models.Beta.EventOutput value, JsonElement? element = null) + public Price(EventOutput value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1715,24 +1720,22 @@ public bool TryPickNewPlanBulk([NotNullWhen(true)] out NewPlanBulkPrice? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickBulkWithFilters(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.BulkWithFilters` + /// // `value` is of type `BulkWithFilters` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickBulkWithFilters( - [NotNullWhen(true)] out global::Orb.Models.Beta.BulkWithFilters? value - ) + public bool TryPickBulkWithFilters([NotNullWhen(true)] out BulkWithFilters? value) { - value = this.Value as global::Orb.Models.Beta.BulkWithFilters; + value = this.Value as BulkWithFilters; return value != null; } @@ -1964,24 +1967,22 @@ public bool TryPickNewPlanMatrixWithAllocation( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickTieredWithProration(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.TieredWithProration` + /// // `value` is of type `TieredWithProration` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTieredWithProration( - [NotNullWhen(true)] out global::Orb.Models.Beta.TieredWithProration? value - ) + public bool TryPickTieredWithProration([NotNullWhen(true)] out TieredWithProration? value) { - value = this.Value as global::Orb.Models.Beta.TieredWithProration; + value = this.Value as TieredWithProration; return value != null; } @@ -2102,24 +2103,24 @@ public bool TryPickNewPlanGroupedWithMeteredMinimum( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickGroupedWithMinMaxThresholds(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.GroupedWithMinMaxThresholds` + /// // `value` is of type `GroupedWithMinMaxThresholds` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] out global::Orb.Models.Beta.GroupedWithMinMaxThresholds? value + [NotNullWhen(true)] out GroupedWithMinMaxThresholds? value ) { - value = this.Value as global::Orb.Models.Beta.GroupedWithMinMaxThresholds; + value = this.Value as GroupedWithMinMaxThresholds; return value != null; } @@ -2263,45 +2264,24 @@ public bool TryPickNewPlanCumulativeGroupedBulk( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.CumulativeGroupedAllocation` + /// // `value` is of type `CumulativeGroupedAllocation` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] out global::Orb.Models.Beta.CumulativeGroupedAllocation? value + [NotNullWhen(true)] out CumulativeGroupedAllocation? value ) { - value = this.Value as global::Orb.Models.Beta.CumulativeGroupedAllocation; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.Minimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum([NotNullWhen(true)] out global::Orb.Models.Beta.Minimum? value) - { - value = this.Value as global::Orb.Models.Beta.Minimum; + value = this.Value as CumulativeGroupedAllocation; return value != null; } @@ -2330,45 +2310,43 @@ public bool TryPickNewPlanMinimumComposite( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickPercent(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.Percent` + /// // `value` is of type `Percent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickPercent([NotNullWhen(true)] out global::Orb.Models.Beta.Percent? value) + public bool TryPickPercent([NotNullWhen(true)] out Percent? value) { - value = this.Value as global::Orb.Models.Beta.Percent; + value = this.Value as Percent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickEventOutput(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.EventOutput` + /// // `value` is of type `EventOutput` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickEventOutput( - [NotNullWhen(true)] out global::Orb.Models.Beta.EventOutput? value - ) + public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) { - value = this.Value as global::Orb.Models.Beta.EventOutput; + value = this.Value as EventOutput; return value != null; } @@ -2389,7 +2367,7 @@ public bool TryPickEventOutput( /// (NewPlanUnitPrice value) => {...}, /// (NewPlanTieredPrice value) => {...}, /// (NewPlanBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.BulkWithFilters value) => {...}, + /// (BulkWithFilters value) => {...}, /// (NewPlanPackagePrice value) => {...}, /// (NewPlanMatrixPrice value) => {...}, /// (NewPlanThresholdTotalAmountPrice value) => {...}, @@ -2400,24 +2378,23 @@ public bool TryPickEventOutput( /// (NewPlanPackageWithAllocationPrice value) => {...}, /// (NewPlanUnitWithPercentPrice value) => {...}, /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Beta.TieredWithProration value) => {...}, + /// (TieredWithProration value) => {...}, /// (NewPlanUnitWithProrationPrice value) => {...}, /// (NewPlanGroupedAllocationPrice value) => {...}, /// (NewPlanBulkWithProrationPrice value) => {...}, /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Beta.GroupedWithMinMaxThresholds value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, /// (NewPlanGroupedTieredPackagePrice value) => {...}, /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.CumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Beta.Minimum value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Beta.Percent value) => {...}, - /// (global::Orb.Models.Beta.EventOutput value) => {...} + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -2426,7 +2403,7 @@ public void Switch( System::Action newPlanUnit, System::Action newPlanTiered, System::Action newPlanBulk, - System::Action bulkWithFilters, + System::Action bulkWithFilters, System::Action newPlanPackage, System::Action newPlanMatrix, System::Action newPlanThresholdTotalAmount, @@ -2437,24 +2414,23 @@ public void Switch( System::Action newPlanPackageWithAllocation, System::Action newPlanUnitWithPercent, System::Action newPlanMatrixWithAllocation, - System::Action tieredWithProration, + System::Action tieredWithProration, System::Action newPlanUnitWithProration, System::Action newPlanGroupedAllocation, System::Action newPlanBulkWithProration, System::Action newPlanGroupedWithProratedMinimum, System::Action newPlanGroupedWithMeteredMinimum, - System::Action groupedWithMinMaxThresholds, + System::Action groupedWithMinMaxThresholds, System::Action newPlanMatrixWithDisplayName, System::Action newPlanGroupedTieredPackage, System::Action newPlanMaxGroupTieredPackage, System::Action newPlanScalableMatrixWithUnitPricing, System::Action newPlanScalableMatrixWithTieredPricing, System::Action newPlanCumulativeGroupedBulk, - System::Action cumulativeGroupedAllocation, - System::Action minimum, + System::Action cumulativeGroupedAllocation, System::Action newPlanMinimumComposite, - System::Action percent, - System::Action eventOutput + System::Action percent, + System::Action eventOutput ) { switch (this.Value) @@ -2468,7 +2444,7 @@ public void Switch( case NewPlanBulkPrice value: newPlanBulk(value); break; - case global::Orb.Models.Beta.BulkWithFilters value: + case BulkWithFilters value: bulkWithFilters(value); break; case NewPlanPackagePrice value: @@ -2501,7 +2477,7 @@ public void Switch( case NewPlanMatrixWithAllocationPrice value: newPlanMatrixWithAllocation(value); break; - case global::Orb.Models.Beta.TieredWithProration value: + case TieredWithProration value: tieredWithProration(value); break; case NewPlanUnitWithProrationPrice value: @@ -2519,7 +2495,7 @@ public void Switch( case NewPlanGroupedWithMeteredMinimumPrice value: newPlanGroupedWithMeteredMinimum(value); break; - case global::Orb.Models.Beta.GroupedWithMinMaxThresholds value: + case GroupedWithMinMaxThresholds value: groupedWithMinMaxThresholds(value); break; case NewPlanMatrixWithDisplayNamePrice value: @@ -2540,19 +2516,16 @@ public void Switch( case NewPlanCumulativeGroupedBulkPrice value: newPlanCumulativeGroupedBulk(value); break; - case global::Orb.Models.Beta.CumulativeGroupedAllocation value: + case CumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case global::Orb.Models.Beta.Minimum value: - minimum(value); - break; case NewPlanMinimumCompositePrice value: newPlanMinimumComposite(value); break; - case global::Orb.Models.Beta.Percent value: + case Percent value: percent(value); break; - case global::Orb.Models.Beta.EventOutput value: + case EventOutput value: eventOutput(value); break; default: @@ -2578,7 +2551,7 @@ public void Switch( /// (NewPlanUnitPrice value) => {...}, /// (NewPlanTieredPrice value) => {...}, /// (NewPlanBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.BulkWithFilters value) => {...}, + /// (BulkWithFilters value) => {...}, /// (NewPlanPackagePrice value) => {...}, /// (NewPlanMatrixPrice value) => {...}, /// (NewPlanThresholdTotalAmountPrice value) => {...}, @@ -2589,24 +2562,23 @@ public void Switch( /// (NewPlanPackageWithAllocationPrice value) => {...}, /// (NewPlanUnitWithPercentPrice value) => {...}, /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Beta.TieredWithProration value) => {...}, + /// (TieredWithProration value) => {...}, /// (NewPlanUnitWithProrationPrice value) => {...}, /// (NewPlanGroupedAllocationPrice value) => {...}, /// (NewPlanBulkWithProrationPrice value) => {...}, /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Beta.GroupedWithMinMaxThresholds value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, /// (NewPlanGroupedTieredPackagePrice value) => {...}, /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.CumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Beta.Minimum value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Beta.Percent value) => {...}, - /// (global::Orb.Models.Beta.EventOutput value) => {...} + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -2615,7 +2587,7 @@ public T Match( System::Func newPlanUnit, System::Func newPlanTiered, System::Func newPlanBulk, - System::Func bulkWithFilters, + System::Func bulkWithFilters, System::Func newPlanPackage, System::Func newPlanMatrix, System::Func newPlanThresholdTotalAmount, @@ -2626,16 +2598,13 @@ public T Match( System::Func newPlanPackageWithAllocation, System::Func newPlanUnitWithPercent, System::Func newPlanMatrixWithAllocation, - System::Func tieredWithProration, + System::Func tieredWithProration, System::Func newPlanUnitWithProration, System::Func newPlanGroupedAllocation, System::Func newPlanBulkWithProration, System::Func newPlanGroupedWithProratedMinimum, System::Func newPlanGroupedWithMeteredMinimum, - System::Func< - global::Orb.Models.Beta.GroupedWithMinMaxThresholds, - T - > groupedWithMinMaxThresholds, + System::Func groupedWithMinMaxThresholds, System::Func newPlanMatrixWithDisplayName, System::Func newPlanGroupedTieredPackage, System::Func newPlanMaxGroupTieredPackage, @@ -2648,14 +2617,10 @@ public T Match( T > newPlanScalableMatrixWithTieredPricing, System::Func newPlanCumulativeGroupedBulk, - System::Func< - global::Orb.Models.Beta.CumulativeGroupedAllocation, - T - > cumulativeGroupedAllocation, - System::Func minimum, + System::Func cumulativeGroupedAllocation, System::Func newPlanMinimumComposite, - System::Func percent, - System::Func eventOutput + System::Func percent, + System::Func eventOutput ) { return this.Value switch @@ -2663,7 +2628,7 @@ public T Match( NewPlanUnitPrice value => newPlanUnit(value), NewPlanTieredPrice value => newPlanTiered(value), NewPlanBulkPrice value => newPlanBulk(value), - global::Orb.Models.Beta.BulkWithFilters value => bulkWithFilters(value), + BulkWithFilters value => bulkWithFilters(value), NewPlanPackagePrice value => newPlanPackage(value), NewPlanMatrixPrice value => newPlanMatrix(value), NewPlanThresholdTotalAmountPrice value => newPlanThresholdTotalAmount(value), @@ -2674,7 +2639,7 @@ public T Match( NewPlanPackageWithAllocationPrice value => newPlanPackageWithAllocation(value), NewPlanUnitWithPercentPrice value => newPlanUnitWithPercent(value), NewPlanMatrixWithAllocationPrice value => newPlanMatrixWithAllocation(value), - global::Orb.Models.Beta.TieredWithProration value => tieredWithProration(value), + TieredWithProration value => tieredWithProration(value), NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), @@ -2682,8 +2647,7 @@ public T Match( value ), NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), - global::Orb.Models.Beta.GroupedWithMinMaxThresholds value => - groupedWithMinMaxThresholds(value), + GroupedWithMinMaxThresholds value => groupedWithMinMaxThresholds(value), NewPlanMatrixWithDisplayNamePrice value => newPlanMatrixWithDisplayName(value), NewPlanGroupedTieredPackagePrice value => newPlanGroupedTieredPackage(value), NewPlanMaxGroupTieredPackagePrice value => newPlanMaxGroupTieredPackage(value), @@ -2693,138 +2657,79 @@ public T Match( NewPlanScalableMatrixWithTieredPricingPrice value => newPlanScalableMatrixWithTieredPricing(value), NewPlanCumulativeGroupedBulkPrice value => newPlanCumulativeGroupedBulk(value), - global::Orb.Models.Beta.CumulativeGroupedAllocation value => - cumulativeGroupedAllocation(value), - global::Orb.Models.Beta.Minimum value => minimum(value), + CumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), - global::Orb.Models.Beta.Percent value => percent(value), - global::Orb.Models.Beta.EventOutput value => eventOutput(value), + Percent value => percent(value), + EventOutput value => eventOutput(value), _ => throw new OrbInvalidDataException("Data did not match any variant of Price"), }; } - public static implicit operator global::Orb.Models.Beta.Price(NewPlanUnitPrice value) => - new(value); - - public static implicit operator global::Orb.Models.Beta.Price(NewPlanTieredPrice value) => - new(value); + public static implicit operator Price(NewPlanUnitPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price(NewPlanBulkPrice value) => - new(value); + public static implicit operator Price(NewPlanTieredPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - global::Orb.Models.Beta.BulkWithFilters value - ) => new(value); + public static implicit operator Price(NewPlanBulkPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price(NewPlanPackagePrice value) => - new(value); + public static implicit operator Price(BulkWithFilters value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price(NewPlanMatrixPrice value) => - new(value); + public static implicit operator Price(NewPlanPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanThresholdTotalAmountPrice value - ) => new(value); + public static implicit operator Price(NewPlanMatrixPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewPlanThresholdTotalAmountPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanTieredWithMinimumPrice value - ) => new(value); + public static implicit operator Price(NewPlanTieredPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanGroupedTieredPrice value - ) => new(value); + public static implicit operator Price(NewPlanTieredWithMinimumPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanTieredPackageWithMinimumPrice value - ) => new(value); + public static implicit operator Price(NewPlanGroupedTieredPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanPackageWithAllocationPrice value - ) => new(value); + public static implicit operator Price(NewPlanTieredPackageWithMinimumPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanUnitWithPercentPrice value - ) => new(value); + public static implicit operator Price(NewPlanPackageWithAllocationPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanMatrixWithAllocationPrice value - ) => new(value); + public static implicit operator Price(NewPlanUnitWithPercentPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - global::Orb.Models.Beta.TieredWithProration value - ) => new(value); + public static implicit operator Price(NewPlanMatrixWithAllocationPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanUnitWithProrationPrice value - ) => new(value); + public static implicit operator Price(TieredWithProration value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanGroupedAllocationPrice value - ) => new(value); + public static implicit operator Price(NewPlanUnitWithProrationPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanBulkWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewPlanGroupedAllocationPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanGroupedWithProratedMinimumPrice value - ) => new(value); + public static implicit operator Price(NewPlanBulkWithProrationPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanGroupedWithMeteredMinimumPrice value - ) => new(value); + public static implicit operator Price(NewPlanGroupedWithProratedMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.Price( - global::Orb.Models.Beta.GroupedWithMinMaxThresholds value - ) => new(value); + public static implicit operator Price(NewPlanGroupedWithMeteredMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanMatrixWithDisplayNamePrice value - ) => new(value); + public static implicit operator Price(GroupedWithMinMaxThresholds value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanGroupedTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewPlanMatrixWithDisplayNamePrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanMaxGroupTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewPlanGroupedTieredPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanScalableMatrixWithUnitPricingPrice value - ) => new(value); + public static implicit operator Price(NewPlanMaxGroupTieredPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanScalableMatrixWithTieredPricingPrice value - ) => new(value); + public static implicit operator Price(NewPlanScalableMatrixWithUnitPricingPrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanCumulativeGroupedBulkPrice value - ) => new(value); + public static implicit operator Price(NewPlanScalableMatrixWithTieredPricingPrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.Price( - global::Orb.Models.Beta.CumulativeGroupedAllocation value - ) => new(value); + public static implicit operator Price(NewPlanCumulativeGroupedBulkPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - global::Orb.Models.Beta.Minimum value - ) => new(value); + public static implicit operator Price(CumulativeGroupedAllocation value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanMinimumCompositePrice value - ) => new(value); + public static implicit operator Price(NewPlanMinimumCompositePrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - global::Orb.Models.Beta.Percent value - ) => new(value); + public static implicit operator Price(Percent value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - global::Orb.Models.Beta.EventOutput value - ) => new(value); + public static implicit operator Price(EventOutput value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2873,14 +2778,13 @@ public override void Validate() newPlanScalableMatrixWithTieredPricing.Validate(), (newPlanCumulativeGroupedBulk) => newPlanCumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), (newPlanMinimumComposite) => newPlanMinimumComposite.Validate(), (percent) => percent.Validate(), (eventOutput) => eventOutput.Validate() ); } - public virtual bool Equals(global::Orb.Models.Beta.Price? other) + public virtual bool Equals(Price? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -2894,9 +2798,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class PriceConverter : JsonConverter +sealed class PriceConverter : JsonConverter { - public override global::Orb.Models.Beta.Price? Read( + public override Price? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -2985,11 +2889,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3230,11 +3133,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3365,11 +3267,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3525,30 +3426,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3592,10 +3470,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3614,11 +3489,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3635,40 +3506,29 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.Price(element); + return new Price(element); } } } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.Price? value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Price? value, JsonSerializerOptions options) { JsonSerializer.Serialize(writer, value?.Json, options); } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.BulkWithFilters, - global::Orb.Models.Beta.BulkWithFiltersFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class BulkWithFilters : JsonModel { /// /// Configuration for bulk_with_filters pricing /// - public required global::Orb.Models.Beta.BulkWithFiltersConfig BulkWithFiltersConfig + public required BulkWithFiltersConfig BulkWithFiltersConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "bulk_with_filters_config" - ); + return this._rawData.GetNotNullClass("bulk_with_filters_config"); } init { this._rawData.Set("bulk_with_filters_config", value); } } @@ -3676,14 +3536,12 @@ public sealed record class BulkWithFilters : JsonModel /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( - "cadence" - ); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } @@ -3786,14 +3644,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.ConversionRateConfig? ConversionRateConfig + public ConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); + return this._rawData.GetNullableClass("conversion_rate_config"); } init { this._rawData.Set("conversion_rate_config", value); } } @@ -3953,7 +3809,7 @@ public BulkWithFilters() this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } - public BulkWithFilters(global::Orb.Models.Beta.BulkWithFilters bulkWithFilters) + public BulkWithFilters(BulkWithFilters bulkWithFilters) : base(bulkWithFilters) { } public BulkWithFilters(IReadOnlyDictionary rawData) @@ -3971,49 +3827,39 @@ public BulkWithFilters(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.BulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class BulkWithFiltersFromRaw : IFromRawJson +class BulkWithFiltersFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.BulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.BulkWithFilters.FromRawUnchecked(rawData); + public BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) => + BulkWithFilters.FromRawUnchecked(rawData); } /// /// Configuration for bulk_with_filters pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.BulkWithFiltersConfig, - global::Orb.Models.Beta.BulkWithFiltersConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class BulkWithFiltersConfig : JsonModel { /// /// Property filters to apply (all must match) /// - public required IReadOnlyList Filters + public required IReadOnlyList Filters { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct>( - "filters" - ); + return this._rawData.GetNotNullStruct>("filters"); } init { - this._rawData.Set>( + this._rawData.Set>( "filters", ImmutableArray.ToImmutableArray(value) ); @@ -4023,18 +3869,16 @@ public sealed record class BulkWithFiltersConfig : JsonModel /// /// Bulk tiers for rating based on total usage volume /// - public required IReadOnlyList Tiers + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct>( - "tiers" - ); + return this._rawData.GetNotNullStruct>("tiers"); } init { - this._rawData.Set>( + this._rawData.Set>( "tiers", ImmutableArray.ToImmutableArray(value) ); @@ -4056,9 +3900,7 @@ public override void Validate() public BulkWithFiltersConfig() { } - public BulkWithFiltersConfig( - global::Orb.Models.Beta.BulkWithFiltersConfig bulkWithFiltersConfig - ) + public BulkWithFiltersConfig(BulkWithFiltersConfig bulkWithFiltersConfig) : base(bulkWithFiltersConfig) { } public BulkWithFiltersConfig(IReadOnlyDictionary rawData) @@ -4074,8 +3916,8 @@ public BulkWithFiltersConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.BulkWithFiltersConfig FromRawUnchecked( + /// + public static BulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4083,23 +3925,18 @@ IReadOnlyDictionary rawData } } -class BulkWithFiltersConfigFromRaw : IFromRawJson +class BulkWithFiltersConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.BulkWithFiltersConfig FromRawUnchecked( + public BulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.BulkWithFiltersConfig.FromRawUnchecked(rawData); + ) => BulkWithFiltersConfig.FromRawUnchecked(rawData); } /// /// Configuration for a single property filter /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.Filter, - global::Orb.Models.Beta.FilterFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Filter : JsonModel { /// @@ -4137,7 +3974,7 @@ public override void Validate() public Filter() { } - public Filter(global::Orb.Models.Beta.Filter filter) + public Filter(Filter filter) : base(filter) { } public Filter(IReadOnlyDictionary rawData) @@ -4153,29 +3990,24 @@ public Filter(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Filter FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class FilterFromRaw : IFromRawJson +class FilterFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.Filter.FromRawUnchecked(rawData); + public Filter FromRawUnchecked(IReadOnlyDictionary rawData) => + Filter.FromRawUnchecked(rawData); } /// /// Configuration for a single bulk pricing tier /// -[JsonConverter( - typeof(JsonModelConverter) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Tier : JsonModel { /// @@ -4213,7 +4045,7 @@ public override void Validate() public Tier() { } - public Tier(global::Orb.Models.Beta.Tier tier) + public Tier(Tier tier) : base(tier) { } public Tier(IReadOnlyDictionary rawData) @@ -4229,10 +4061,8 @@ public Tier(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Tier FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } @@ -4245,18 +4075,17 @@ public Tier(string unitAmount) } } -class TierFromRaw : IFromRawJson +class TierFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.Tier.FromRawUnchecked(rawData); + public Tier FromRawUnchecked(IReadOnlyDictionary rawData) => + Tier.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.CadenceConverter))] +[JsonConverter(typeof(CadenceConverter))] public enum Cadence { Annual, @@ -4267,9 +4096,9 @@ public enum Cadence Custom, } -sealed class CadenceConverter : JsonConverter +sealed class CadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.Cadence Read( + public override Cadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4277,32 +4106,28 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Beta.Cadence.Annual, - "semi_annual" => global::Orb.Models.Beta.Cadence.SemiAnnual, - "monthly" => global::Orb.Models.Beta.Cadence.Monthly, - "quarterly" => global::Orb.Models.Beta.Cadence.Quarterly, - "one_time" => global::Orb.Models.Beta.Cadence.OneTime, - "custom" => global::Orb.Models.Beta.Cadence.Custom, - _ => (global::Orb.Models.Beta.Cadence)(-1), + "annual" => Cadence.Annual, + "semi_annual" => Cadence.SemiAnnual, + "monthly" => Cadence.Monthly, + "quarterly" => Cadence.Quarterly, + "one_time" => Cadence.OneTime, + "custom" => Cadence.Custom, + _ => (Cadence)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.Cadence value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Cadence value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Beta.Cadence.Annual => "annual", - global::Orb.Models.Beta.Cadence.SemiAnnual => "semi_annual", - global::Orb.Models.Beta.Cadence.Monthly => "monthly", - global::Orb.Models.Beta.Cadence.Quarterly => "quarterly", - global::Orb.Models.Beta.Cadence.OneTime => "one_time", - global::Orb.Models.Beta.Cadence.Custom => "custom", + Cadence.Annual => "annual", + Cadence.SemiAnnual => "semi_annual", + Cadence.Monthly => "monthly", + Cadence.Quarterly => "quarterly", + Cadence.OneTime => "one_time", + Cadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -4312,7 +4137,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.Beta.ConversionRateConfigConverter))] +[JsonConverter(typeof(ConversionRateConfigConverter))] public record class ConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -4465,13 +4290,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Beta.ConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); + public static implicit operator ConversionRateConfig(SharedUnitConversionRateConfig value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); + public static implicit operator ConversionRateConfig(SharedTieredConversionRateConfig value) => + new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -4494,7 +4317,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Beta.ConversionRateConfig? other) + public virtual bool Equals(ConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -4508,10 +4331,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class ConversionRateConfigConverter - : JsonConverter +sealed class ConversionRateConfigConverter : JsonConverter { - public override global::Orb.Models.Beta.ConversionRateConfig? Read( + public override ConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4576,14 +4398,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ConversionRateConfig(element); + return new ConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ConversionRateConfig value, + ConversionRateConfig value, JsonSerializerOptions options ) { @@ -4591,25 +4413,20 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.TieredWithProration, - global::Orb.Models.Beta.TieredWithProrationFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class TieredWithProration : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } init { this._rawData.Set("cadence", value); } } @@ -4656,12 +4473,12 @@ public required string Name /// /// Configuration for tiered_with_proration pricing /// - public required global::Orb.Models.Beta.TieredWithProrationConfig TieredWithProrationConfig + public required TieredWithProrationConfig TieredWithProrationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "tiered_with_proration_config" ); } @@ -4727,12 +4544,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.TieredWithProrationConversionRateConfig? ConversionRateConfig + public TieredWithProrationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -4894,7 +4711,7 @@ public TieredWithProration() this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } - public TieredWithProration(global::Orb.Models.Beta.TieredWithProration tieredWithProration) + public TieredWithProration(TieredWithProration tieredWithProration) : base(tieredWithProration) { } public TieredWithProration(IReadOnlyDictionary rawData) @@ -4912,8 +4729,8 @@ public TieredWithProration(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.TieredWithProration FromRawUnchecked( + /// + public static TieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4921,18 +4738,17 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationFromRaw : IFromRawJson +class TieredWithProrationFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.TieredWithProration FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.TieredWithProration.FromRawUnchecked(rawData); + public TieredWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredWithProration.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.TieredWithProrationCadenceConverter))] +[JsonConverter(typeof(TieredWithProrationCadenceConverter))] public enum TieredWithProrationCadence { Annual, @@ -4943,10 +4759,9 @@ public enum TieredWithProrationCadence Custom, } -sealed class TieredWithProrationCadenceConverter - : JsonConverter +sealed class TieredWithProrationCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.TieredWithProrationCadence Read( + public override TieredWithProrationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4954,19 +4769,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Beta.TieredWithProrationCadence.Annual, - "semi_annual" => global::Orb.Models.Beta.TieredWithProrationCadence.SemiAnnual, - "monthly" => global::Orb.Models.Beta.TieredWithProrationCadence.Monthly, - "quarterly" => global::Orb.Models.Beta.TieredWithProrationCadence.Quarterly, - "one_time" => global::Orb.Models.Beta.TieredWithProrationCadence.OneTime, - "custom" => global::Orb.Models.Beta.TieredWithProrationCadence.Custom, - _ => (global::Orb.Models.Beta.TieredWithProrationCadence)(-1), + "annual" => TieredWithProrationCadence.Annual, + "semi_annual" => TieredWithProrationCadence.SemiAnnual, + "monthly" => TieredWithProrationCadence.Monthly, + "quarterly" => TieredWithProrationCadence.Quarterly, + "one_time" => TieredWithProrationCadence.OneTime, + "custom" => TieredWithProrationCadence.Custom, + _ => (TieredWithProrationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.TieredWithProrationCadence value, + TieredWithProrationCadence value, JsonSerializerOptions options ) { @@ -4974,12 +4789,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Beta.TieredWithProrationCadence.Annual => "annual", - global::Orb.Models.Beta.TieredWithProrationCadence.SemiAnnual => "semi_annual", - global::Orb.Models.Beta.TieredWithProrationCadence.Monthly => "monthly", - global::Orb.Models.Beta.TieredWithProrationCadence.Quarterly => "quarterly", - global::Orb.Models.Beta.TieredWithProrationCadence.OneTime => "one_time", - global::Orb.Models.Beta.TieredWithProrationCadence.Custom => "custom", + TieredWithProrationCadence.Annual => "annual", + TieredWithProrationCadence.SemiAnnual => "semi_annual", + TieredWithProrationCadence.Monthly => "monthly", + TieredWithProrationCadence.Quarterly => "quarterly", + TieredWithProrationCadence.OneTime => "one_time", + TieredWithProrationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -4993,10 +4808,7 @@ JsonSerializerOptions options /// Configuration for tiered_with_proration pricing /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.TieredWithProrationConfig, - global::Orb.Models.Beta.TieredWithProrationConfigFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class TieredWithProrationConfig : JsonModel { @@ -5004,20 +4816,21 @@ public sealed record class TieredWithProrationConfig : JsonModel /// Tiers for rating based on total usage quantities into the specified tier /// with proration /// - public required IReadOnlyList Tiers + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + return this._rawData.GetNotNullStruct>( + "tiers" + ); } init { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); } } @@ -5032,9 +4845,7 @@ public override void Validate() public TieredWithProrationConfig() { } - public TieredWithProrationConfig( - global::Orb.Models.Beta.TieredWithProrationConfig tieredWithProrationConfig - ) + public TieredWithProrationConfig(TieredWithProrationConfig tieredWithProrationConfig) : base(tieredWithProrationConfig) { } public TieredWithProrationConfig(IReadOnlyDictionary rawData) @@ -5050,8 +4861,8 @@ public TieredWithProrationConfig(IReadOnlyDictionary rawDat } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.TieredWithProrationConfig FromRawUnchecked( + /// + public static TieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5059,32 +4870,26 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public TieredWithProrationConfig( - IReadOnlyList tiers - ) + public TieredWithProrationConfig(IReadOnlyList tiers) : this() { this.Tiers = tiers; } } -class TieredWithProrationConfigFromRaw - : IFromRawJson +class TieredWithProrationConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.TieredWithProrationConfig FromRawUnchecked( + public TieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.TieredWithProrationConfig.FromRawUnchecked(rawData); + ) => TieredWithProrationConfig.FromRawUnchecked(rawData); } /// /// Configuration for a single tiered with proration tier /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.TieredWithProrationConfigTier, - global::Orb.Models.Beta.TieredWithProrationConfigTierFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class TieredWithProrationConfigTier : JsonModel { @@ -5124,7 +4929,7 @@ public override void Validate() public TieredWithProrationConfigTier() { } public TieredWithProrationConfigTier( - global::Orb.Models.Beta.TieredWithProrationConfigTier tieredWithProrationConfigTier + TieredWithProrationConfigTier tieredWithProrationConfigTier ) : base(tieredWithProrationConfigTier) { } @@ -5141,8 +4946,8 @@ public TieredWithProrationConfigTier(IReadOnlyDictionary ra } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.TieredWithProrationConfigTier FromRawUnchecked( + /// + public static TieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5150,16 +4955,15 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationConfigTierFromRaw - : IFromRawJson +class TieredWithProrationConfigTierFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.TieredWithProrationConfigTier FromRawUnchecked( + public TieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.TieredWithProrationConfigTier.FromRawUnchecked(rawData); + ) => TieredWithProrationConfigTier.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.TieredWithProrationConversionRateConfigConverter))] +[JsonConverter(typeof(TieredWithProrationConversionRateConfigConverter))] public record class TieredWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5318,11 +5122,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Beta.TieredWithProrationConversionRateConfig( + public static implicit operator TieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.TieredWithProrationConversionRateConfig( + public static implicit operator TieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -5347,9 +5151,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.TieredWithProrationConversionRateConfig? other - ) + public virtual bool Equals(TieredWithProrationConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -5364,9 +5166,9 @@ public override string ToString() => } sealed class TieredWithProrationConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.TieredWithProrationConversionRateConfig? Read( + public override TieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5431,14 +5233,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.TieredWithProrationConversionRateConfig(element); + return new TieredWithProrationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.TieredWithProrationConversionRateConfig value, + TieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -5447,26 +5249,20 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.GroupedWithMinMaxThresholds, - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class GroupedWithMinMaxThresholds : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -5475,12 +5271,12 @@ public required ApiEnum< /// /// Configuration for grouped_with_min_max_thresholds pricing /// - public required global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + public required GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "grouped_with_min_max_thresholds_config" ); } @@ -5585,12 +5381,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + public GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5752,9 +5548,7 @@ public GroupedWithMinMaxThresholds() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } - public GroupedWithMinMaxThresholds( - global::Orb.Models.Beta.GroupedWithMinMaxThresholds groupedWithMinMaxThresholds - ) + public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) : base(groupedWithMinMaxThresholds) { } public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) @@ -5772,8 +5566,8 @@ public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawD } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.GroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5781,19 +5575,18 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class GroupedWithMinMaxThresholdsFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.GroupedWithMinMaxThresholds FromRawUnchecked( + public GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + ) => GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadenceConverter))] +[JsonConverter(typeof(GroupedWithMinMaxThresholdsCadenceConverter))] public enum GroupedWithMinMaxThresholdsCadence { Annual, @@ -5805,9 +5598,9 @@ public enum GroupedWithMinMaxThresholdsCadence } sealed class GroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadence Read( + public override GroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5815,19 +5608,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadence.Annual, - "semi_annual" => global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadence.SemiAnnual, - "monthly" => global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadence.Monthly, - "quarterly" => global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadence.Quarterly, - "one_time" => global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadence.OneTime, - "custom" => global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadence.Custom, - _ => (global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadence)(-1), + "annual" => GroupedWithMinMaxThresholdsCadence.Annual, + "semi_annual" => GroupedWithMinMaxThresholdsCadence.SemiAnnual, + "monthly" => GroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => GroupedWithMinMaxThresholdsCadence.Quarterly, + "one_time" => GroupedWithMinMaxThresholdsCadence.OneTime, + "custom" => GroupedWithMinMaxThresholdsCadence.Custom, + _ => (GroupedWithMinMaxThresholdsCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadence value, + GroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -5835,13 +5628,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadence.Annual => "annual", - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadence.SemiAnnual => - "semi_annual", - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadence.Monthly => "monthly", - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadence.OneTime => "one_time", - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadence.Custom => "custom", + GroupedWithMinMaxThresholdsCadence.Annual => "annual", + GroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", + GroupedWithMinMaxThresholdsCadence.Monthly => "monthly", + GroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", + GroupedWithMinMaxThresholdsCadence.OneTime => "one_time", + GroupedWithMinMaxThresholdsCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -5856,8 +5648,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfig, - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfigFromRaw + GroupedWithMinMaxThresholdsConfig, + GroupedWithMinMaxThresholdsConfigFromRaw >) )] public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel @@ -5926,7 +5718,7 @@ public override void Validate() public GroupedWithMinMaxThresholdsConfig() { } public GroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig + GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) : base(groupedWithMinMaxThresholdsConfig) { } @@ -5943,8 +5735,8 @@ public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary - public static global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5952,18 +5744,15 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class GroupedWithMinMaxThresholdsConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); + ) => GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfigConverter) -)] +[JsonConverter(typeof(GroupedWithMinMaxThresholdsConversionRateConfigConverter))] public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6122,11 +5911,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6151,9 +5940,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfig? other - ) + public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -6168,9 +5955,9 @@ public override string ToString() => } sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override GroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6235,16 +6022,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfig( - element - ); + return new GroupedWithMinMaxThresholdsConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfig value, + GroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -6253,26 +6038,20 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.CumulativeGroupedAllocation, - global::Orb.Models.Beta.CumulativeGroupedAllocationFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class CumulativeGroupedAllocation : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.CumulativeGroupedAllocationCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -6281,12 +6060,12 @@ public required ApiEnum< /// /// Configuration for cumulative_grouped_allocation pricing /// - public required global::Orb.Models.Beta.CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "cumulative_grouped_allocation_config" ); } @@ -6391,12 +6170,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + public CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -6558,9 +6337,7 @@ public CumulativeGroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public CumulativeGroupedAllocation( - global::Orb.Models.Beta.CumulativeGroupedAllocation cumulativeGroupedAllocation - ) + public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) : base(cumulativeGroupedAllocation) { } public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) @@ -6578,8 +6355,8 @@ public CumulativeGroupedAllocation(IReadOnlyDictionary rawD } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.CumulativeGroupedAllocation FromRawUnchecked( + /// + public static CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6587,19 +6364,18 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationFromRaw - : IFromRawJson +class CumulativeGroupedAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.CumulativeGroupedAllocation FromRawUnchecked( + public CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.CumulativeGroupedAllocation.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.CumulativeGroupedAllocationCadenceConverter))] +[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] public enum CumulativeGroupedAllocationCadence { Annual, @@ -6611,9 +6387,9 @@ public enum CumulativeGroupedAllocationCadence } sealed class CumulativeGroupedAllocationCadenceConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.CumulativeGroupedAllocationCadence Read( + public override CumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6621,19 +6397,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Beta.CumulativeGroupedAllocationCadence.Annual, - "semi_annual" => global::Orb.Models.Beta.CumulativeGroupedAllocationCadence.SemiAnnual, - "monthly" => global::Orb.Models.Beta.CumulativeGroupedAllocationCadence.Monthly, - "quarterly" => global::Orb.Models.Beta.CumulativeGroupedAllocationCadence.Quarterly, - "one_time" => global::Orb.Models.Beta.CumulativeGroupedAllocationCadence.OneTime, - "custom" => global::Orb.Models.Beta.CumulativeGroupedAllocationCadence.Custom, - _ => (global::Orb.Models.Beta.CumulativeGroupedAllocationCadence)(-1), + "annual" => CumulativeGroupedAllocationCadence.Annual, + "semi_annual" => CumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => CumulativeGroupedAllocationCadence.Monthly, + "quarterly" => CumulativeGroupedAllocationCadence.Quarterly, + "one_time" => CumulativeGroupedAllocationCadence.OneTime, + "custom" => CumulativeGroupedAllocationCadence.Custom, + _ => (CumulativeGroupedAllocationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.CumulativeGroupedAllocationCadence value, + CumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -6641,13 +6417,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Beta.CumulativeGroupedAllocationCadence.Annual => "annual", - global::Orb.Models.Beta.CumulativeGroupedAllocationCadence.SemiAnnual => - "semi_annual", - global::Orb.Models.Beta.CumulativeGroupedAllocationCadence.Monthly => "monthly", - global::Orb.Models.Beta.CumulativeGroupedAllocationCadence.Quarterly => "quarterly", - global::Orb.Models.Beta.CumulativeGroupedAllocationCadence.OneTime => "one_time", - global::Orb.Models.Beta.CumulativeGroupedAllocationCadence.Custom => "custom", + CumulativeGroupedAllocationCadence.Annual => "annual", + CumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", + CumulativeGroupedAllocationCadence.Monthly => "monthly", + CumulativeGroupedAllocationCadence.Quarterly => "quarterly", + CumulativeGroupedAllocationCadence.OneTime => "one_time", + CumulativeGroupedAllocationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -6662,8 +6437,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.CumulativeGroupedAllocationConfig, - global::Orb.Models.Beta.CumulativeGroupedAllocationConfigFromRaw + CumulativeGroupedAllocationConfig, + CumulativeGroupedAllocationConfigFromRaw >) )] public sealed record class CumulativeGroupedAllocationConfig : JsonModel @@ -6732,7 +6507,7 @@ public override void Validate() public CumulativeGroupedAllocationConfig() { } public CumulativeGroupedAllocationConfig( - global::Orb.Models.Beta.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig ) : base(cumulativeGroupedAllocationConfig) { } @@ -6749,8 +6524,8 @@ public CumulativeGroupedAllocationConfig(IReadOnlyDictionary - public static global::Orb.Models.Beta.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6758,18 +6533,15 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class CumulativeGroupedAllocationConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.CumulativeGroupedAllocationConfig FromRawUnchecked( + public CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfigConverter) -)] +[JsonConverter(typeof(CumulativeGroupedAllocationConversionRateConfigConverter))] public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6928,11 +6700,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6957,9 +6729,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfig? other - ) + public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -6974,9 +6744,9 @@ public override string ToString() => } sealed class CumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfig? Read( + public override CumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7041,16 +6811,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfig( - element - ); + return new CumulativeGroupedAllocationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfig value, + CumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -7058,23 +6826,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.Minimum, - global::Orb.Models.Beta.MinimumFromRaw - >) -)] -public sealed record class Minimum : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Percent : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>("cadence"); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } @@ -7092,21 +6855,6 @@ public required string ItemID init { this._rawData.Set("item_id", value); } } - /// - /// Configuration for minimum pricing - /// - public required global::Orb.Models.Beta.MinimumConfig MinimumConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" - ); - } - init { this._rawData.Set("minimum_config", value); } - } - /// /// The pricing model type /// @@ -7133,6 +6881,19 @@ public required string Name init { this._rawData.Set("name", value); } } + /// + /// Configuration for percent pricing + /// + public required PercentConfig PercentConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("percent_config"); + } + init { this._rawData.Set("percent_config", value); } + } + /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -7192,12 +6953,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public MinimumConversionRateConfig? ConversionRateConfig + public PercentConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -7328,12 +7089,12 @@ public override void Validate() { this.Cadence.Validate(); _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("percent"))) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; + this.PercentConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -7349,51 +7110,48 @@ public override void Validate() _ = this.ReferenceID; } - public Minimum() + public Percent() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public Minimum(global::Orb.Models.Beta.Minimum minimum) - : base(minimum) { } + public Percent(Percent percent) + : base(percent) { } - public Minimum(IReadOnlyDictionary rawData) + public Percent(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Minimum(FrozenDictionary rawData) + Percent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Percent FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class MinimumFromRaw : IFromRawJson +class PercentFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.Minimum.FromRawUnchecked(rawData); + public Percent FromRawUnchecked(IReadOnlyDictionary rawData) => + Percent.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(MinimumCadenceConverter))] -public enum MinimumCadence +[JsonConverter(typeof(PercentCadenceConverter))] +public enum PercentCadence { Annual, SemiAnnual, @@ -7403,9 +7161,9 @@ public enum MinimumCadence Custom, } -sealed class MinimumCadenceConverter : JsonConverter +sealed class PercentCadenceConverter : JsonConverter { - public override MinimumCadence Read( + public override PercentCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7413,19 +7171,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => MinimumCadence.Annual, - "semi_annual" => MinimumCadence.SemiAnnual, - "monthly" => MinimumCadence.Monthly, - "quarterly" => MinimumCadence.Quarterly, - "one_time" => MinimumCadence.OneTime, - "custom" => MinimumCadence.Custom, - _ => (MinimumCadence)(-1), + "annual" => PercentCadence.Annual, + "semi_annual" => PercentCadence.SemiAnnual, + "monthly" => PercentCadence.Monthly, + "quarterly" => PercentCadence.Quarterly, + "one_time" => PercentCadence.OneTime, + "custom" => PercentCadence.Custom, + _ => (PercentCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - MinimumCadence value, + PercentCadence value, JsonSerializerOptions options ) { @@ -7433,12 +7191,12 @@ JsonSerializerOptions options writer, value switch { - MinimumCadence.Annual => "annual", - MinimumCadence.SemiAnnual => "semi_annual", - MinimumCadence.Monthly => "monthly", - MinimumCadence.Quarterly => "quarterly", - MinimumCadence.OneTime => "one_time", - MinimumCadence.Custom => "custom", + PercentCadence.Annual => "annual", + PercentCadence.SemiAnnual => "semi_annual", + PercentCadence.Monthly => "monthly", + PercentCadence.Quarterly => "quarterly", + PercentCadence.OneTime => "one_time", + PercentCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -7449,101 +7207,71 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for percent pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.MinimumConfig, - global::Orb.Models.Beta.MinimumConfigFromRaw - >) -)] -public sealed record class MinimumConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PercentConfig : JsonModel { /// - /// The minimum amount to apply - /// - public required string MinimumAmount - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); - } - init { this._rawData.Set("minimum_amount", value); } - } - - /// - /// If true, subtotals from this price are prorated based on the service period + /// What percent of the component subtotals to charge /// - public bool? Prorated + public required double Percent { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); - } - init - { - if (value == null) - { - return; - } - - this._rawData.Set("prorated", value); + return this._rawData.GetNotNullStruct("percent"); } + init { this._rawData.Set("percent", value); } } /// public override void Validate() { - _ = this.MinimumAmount; - _ = this.Prorated; + _ = this.Percent; } - public MinimumConfig() { } + public PercentConfig() { } - public MinimumConfig(global::Orb.Models.Beta.MinimumConfig minimumConfig) - : base(minimumConfig) { } + public PercentConfig(PercentConfig percentConfig) + : base(percentConfig) { } - public MinimumConfig(IReadOnlyDictionary rawData) + public PercentConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - MinimumConfig(FrozenDictionary rawData) + PercentConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } [SetsRequiredMembers] - public MinimumConfig(string minimumAmount) + public PercentConfig(double percent) : this() { - this.MinimumAmount = minimumAmount; + this.Percent = percent; } } -class MinimumConfigFromRaw : IFromRawJson +class PercentConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.MinimumConfig.FromRawUnchecked(rawData); + public PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + PercentConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(MinimumConversionRateConfigConverter))] -public record class MinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(PercentConversionRateConfigConverter))] +public record class PercentConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -7560,7 +7288,7 @@ public JsonElement Json } } - public MinimumConversionRateConfig( + public PercentConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7569,7 +7297,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig( + public PercentConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7578,7 +7306,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig(JsonElement element) + public PercentConversionRateConfig(JsonElement element) { this._element = element; } @@ -7660,7 +7388,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of PercentConversionRateConfig" ); } } @@ -7696,16 +7424,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of PercentConversionRateConfig" ), }; } - public static implicit operator MinimumConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator MinimumConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7724,13 +7452,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of PercentConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(MinimumConversionRateConfig? other) + public virtual bool Equals(PercentConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -7744,9 +7472,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class MinimumConversionRateConfigConverter : JsonConverter +sealed class PercentConversionRateConfigConverter : JsonConverter { - public override MinimumConversionRateConfig? Read( + public override PercentConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7811,14 +7539,14 @@ JsonSerializerOptions options } default: { - return new MinimumConversionRateConfig(element); + return new PercentConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - MinimumConversionRateConfig value, + PercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -7826,29 +7554,35 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.Percent, - global::Orb.Models.Beta.PercentFromRaw - >) -)] -public sealed record class Percent : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class EventOutput : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } + /// + /// Configuration for event_output pricing + /// + public required EventOutputConfig EventOutputConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("event_output_config"); + } + init { this._rawData.Set("event_output_config", value); } + } + /// /// The id of the item the price will be associated with. /// @@ -7888,21 +7622,6 @@ public required string Name init { this._rawData.Set("name", value); } } - /// - /// Configuration for percent pricing - /// - public required global::Orb.Models.Beta.PercentConfig PercentConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "percent_config" - ); - } - init { this._rawData.Set("percent_config", value); } - } - /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -7962,12 +7681,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.PercentConversionRateConfig? ConversionRateConfig + public EventOutputConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8097,13 +7816,18 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); + this.EventOutputConfig.Validate(); _ = this.ItemID; - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("percent"))) + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("event_output") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.PercentConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -8119,51 +7843,48 @@ public override void Validate() _ = this.ReferenceID; } - public Percent() + public EventOutput() { - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("event_output"); } - public Percent(global::Orb.Models.Beta.Percent percent) - : base(percent) { } + public EventOutput(EventOutput eventOutput) + : base(eventOutput) { } - public Percent(IReadOnlyDictionary rawData) + public EventOutput(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("event_output"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Percent(FrozenDictionary rawData) + EventOutput(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PercentFromRaw : IFromRawJson +class EventOutputFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.Percent.FromRawUnchecked(rawData); + public EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutput.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.PercentCadenceConverter))] -public enum PercentCadence +[JsonConverter(typeof(EventOutputCadenceConverter))] +public enum EventOutputCadence { Annual, SemiAnnual, @@ -8173,9 +7894,9 @@ public enum PercentCadence Custom, } -sealed class PercentCadenceConverter : JsonConverter +sealed class EventOutputCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.PercentCadence Read( + public override EventOutputCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8183,19 +7904,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Beta.PercentCadence.Annual, - "semi_annual" => global::Orb.Models.Beta.PercentCadence.SemiAnnual, - "monthly" => global::Orb.Models.Beta.PercentCadence.Monthly, - "quarterly" => global::Orb.Models.Beta.PercentCadence.Quarterly, - "one_time" => global::Orb.Models.Beta.PercentCadence.OneTime, - "custom" => global::Orb.Models.Beta.PercentCadence.Custom, - _ => (global::Orb.Models.Beta.PercentCadence)(-1), + "annual" => EventOutputCadence.Annual, + "semi_annual" => EventOutputCadence.SemiAnnual, + "monthly" => EventOutputCadence.Monthly, + "quarterly" => EventOutputCadence.Quarterly, + "one_time" => EventOutputCadence.OneTime, + "custom" => EventOutputCadence.Custom, + _ => (EventOutputCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.PercentCadence value, + EventOutputCadence value, JsonSerializerOptions options ) { @@ -8203,12 +7924,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Beta.PercentCadence.Annual => "annual", - global::Orb.Models.Beta.PercentCadence.SemiAnnual => "semi_annual", - global::Orb.Models.Beta.PercentCadence.Monthly => "monthly", - global::Orb.Models.Beta.PercentCadence.Quarterly => "quarterly", - global::Orb.Models.Beta.PercentCadence.OneTime => "one_time", - global::Orb.Models.Beta.PercentCadence.Custom => "custom", + EventOutputCadence.Annual => "annual", + EventOutputCadence.SemiAnnual => "semi_annual", + EventOutputCadence.Monthly => "monthly", + EventOutputCadence.Quarterly => "quarterly", + EventOutputCadence.OneTime => "one_time", + EventOutputCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -8219,55 +7940,81 @@ JsonSerializerOptions options } /// -/// Configuration for percent pricing +/// Configuration for event_output pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.PercentConfig, - global::Orb.Models.Beta.PercentConfigFromRaw - >) -)] -public sealed record class PercentConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class EventOutputConfig : JsonModel { /// - /// What percent of the component subtotals to charge + /// The key in the event data to extract the unit rate from. /// - public required double Percent + public required string UnitRatingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("percent"); + return this._rawData.GetNotNullClass("unit_rating_key"); } - init { this._rawData.Set("percent", value); } + init { this._rawData.Set("unit_rating_key", value); } + } + + /// + /// If provided, this amount will be used as the unit rate when an event does + /// not have a value for the `unit_rating_key`. If not provided, events missing + /// a unit rate will be ignored. + /// + public string? DefaultUnitRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("default_unit_rate"); + } + init { this._rawData.Set("default_unit_rate", value); } + } + + /// + /// An optional key in the event data to group by (e.g., event ID). All events + /// will also be grouped by their unit rate. + /// + public string? GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } } /// public override void Validate() { - _ = this.Percent; + _ = this.UnitRatingKey; + _ = this.DefaultUnitRate; + _ = this.GroupingKey; } - public PercentConfig() { } + public EventOutputConfig() { } - public PercentConfig(global::Orb.Models.Beta.PercentConfig percentConfig) - : base(percentConfig) { } + public EventOutputConfig(EventOutputConfig eventOutputConfig) + : base(eventOutputConfig) { } - public PercentConfig(IReadOnlyDictionary rawData) + public EventOutputConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - PercentConfig(FrozenDictionary rawData) + EventOutputConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.PercentConfig FromRawUnchecked( + /// + public static EventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8275,23 +8022,22 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public PercentConfig(double percent) + public EventOutputConfig(string unitRatingKey) : this() { - this.Percent = percent; + this.UnitRatingKey = unitRatingKey; } } -class PercentConfigFromRaw : IFromRawJson +class EventOutputConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.PercentConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.PercentConfig.FromRawUnchecked(rawData); + public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutputConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.PercentConversionRateConfigConverter))] -public record class PercentConversionRateConfig : ModelBase +[JsonConverter(typeof(EventOutputConversionRateConfigConverter))] +public record class EventOutputConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -8308,7 +8054,7 @@ public JsonElement Json } } - public PercentConversionRateConfig( + public EventOutputConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8317,7 +8063,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig( + public EventOutputConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8326,7 +8072,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig(JsonElement element) + public EventOutputConversionRateConfig(JsonElement element) { this._element = element; } @@ -8408,7 +8154,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" + "Data did not match any variant of EventOutputConversionRateConfig" ); } } @@ -8444,16 +8190,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" + "Data did not match any variant of EventOutputConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.PercentConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.PercentConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -8472,13 +8218,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" + "Data did not match any variant of EventOutputConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Beta.PercentConversionRateConfig? other) + public virtual bool Equals(EventOutputConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -8492,10 +8238,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class PercentConversionRateConfigConverter - : JsonConverter +sealed class EventOutputConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.PercentConversionRateConfig? Read( + public override EventOutputConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8560,14 +8306,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.PercentConversionRateConfig(element); + return new EventOutputConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.PercentConversionRateConfig value, + EventOutputConversionRateConfig value, JsonSerializerOptions options ) { @@ -8575,329 +8321,228 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.EventOutput, - global::Orb.Models.Beta.EventOutputFromRaw - >) -)] -public sealed record class EventOutput : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class RemoveAdjustment : JsonModel { /// - /// The cadence to bill for this price on. + /// The id of the adjustment to remove from on the plan. /// - public required ApiEnum Cadence + public required string AdjustmentID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass("adjustment_id"); } - init { this._rawData.Set("cadence", value); } + init { this._rawData.Set("adjustment_id", value); } } /// - /// Configuration for event_output pricing + /// The phase to remove this adjustment from. /// - public required global::Orb.Models.Beta.EventOutputConfig EventOutputConfig + public long? PlanPhaseOrder { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "event_output_config" - ); + return this._rawData.GetNullableStruct("plan_phase_order"); } - init { this._rawData.Set("event_output_config", value); } + init { this._rawData.Set("plan_phase_order", value); } } - /// - /// The id of the item the price will be associated with. - /// - public required string ItemID + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); - } - init { this._rawData.Set("item_id", value); } + _ = this.AdjustmentID; + _ = this.PlanPhaseOrder; } - /// - /// The pricing model type - /// - public JsonElement ModelType + public RemoveAdjustment() { } + + public RemoveAdjustment(RemoveAdjustment removeAdjustment) + : base(removeAdjustment) { } + + public RemoveAdjustment(IReadOnlyDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); - } - init { this._rawData.Set("model_type", value); } + this._rawData = new(rawData); } - /// - /// The name of the price. - /// - public required string Name +#pragma warning disable CS8618 + [SetsRequiredMembers] + RemoveAdjustment(FrozenDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } + this._rawData = new(rawData); } +#pragma warning restore CS8618 - /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. - /// - public string? BillableMetricID + /// + public static RemoveAdjustment FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); - } - init { this._rawData.Set("billable_metric_id", value); } + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. - /// - public bool? BilledInAdvance + [SetsRequiredMembers] + public RemoveAdjustment(string adjustmentID) + : this() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); - } - init { this._rawData.Set("billed_in_advance", value); } + this.AdjustmentID = adjustmentID; } +} - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } - } +class RemoveAdjustmentFromRaw : IFromRawJson +{ + /// + public RemoveAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => + RemoveAdjustment.FromRawUnchecked(rawData); +} +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class RemovePrice : JsonModel +{ /// - /// The per unit conversion rate of the price currency to the invoicing currency. + /// The id of the price to remove from the plan. /// - public double? ConversionRate + public required string PriceID { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); + return this._rawData.GetNotNullClass("price_id"); } - init { this._rawData.Set("conversion_rate", value); } + init { this._rawData.Set("price_id", value); } } /// - /// The configuration for the rate of the price currency to the invoicing currency. + /// The phase to remove this price from. /// - public global::Orb.Models.Beta.EventOutputConversionRateConfig? ConversionRateConfig + public long? PlanPhaseOrder { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); + return this._rawData.GetNullableStruct("plan_phase_order"); } - init { this._rawData.Set("conversion_rate_config", value); } + init { this._rawData.Set("plan_phase_order", value); } } - /// - /// An ISO 4217 currency string, or custom pricing unit identifier, in which - /// this price is billed. - /// - public string? Currency + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("currency"); - } - init { this._rawData.Set("currency", value); } + _ = this.PriceID; + _ = this.PlanPhaseOrder; } - /// - /// For dimensional price: specifies a price group and dimension values - /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + public RemovePrice() { } + + public RemovePrice(RemovePrice removePrice) + : base(removePrice) { } + + public RemovePrice(IReadOnlyDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } + this._rawData = new(rawData); } - /// - /// An alias for the price. - /// - public string? ExternalPriceID +#pragma warning disable CS8618 + [SetsRequiredMembers] + RemovePrice(FrozenDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } + this._rawData = new(rawData); } +#pragma warning restore CS8618 - /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. - /// - public double? FixedPriceQuantity + /// + public static RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey + [SetsRequiredMembers] + public RemovePrice(string priceID) + : this() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", value); } + this.PriceID = priceID; } +} + +class RemovePriceFromRaw : IFromRawJson +{ + /// + public RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) => + RemovePrice.FromRawUnchecked(rawData); +} +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ReplaceAdjustment : JsonModel +{ /// - /// Within each billing cycle, specifies the cadence at which invoices are produced. - /// If unspecified, a single invoice is produced per billing cycle. + /// The definition of a new adjustment to create and add to the plan. /// - public NewBillingCycleConfiguration? InvoicingCycleConfiguration + public required ReplaceAdjustmentAdjustment Adjustment { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); + return this._rawData.GetNotNullClass("adjustment"); } - init { this._rawData.Set("invoicing_cycle_configuration", value); } + init { this._rawData.Set("adjustment", value); } } /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared - /// by setting `metadata` to `null`. + /// The id of the adjustment on the plan to replace in the plan. /// - public IReadOnlyDictionary? Metadata + public required string ReplacesAdjustmentID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) - ); + return this._rawData.GetNotNullClass("replaces_adjustment_id"); } + init { this._rawData.Set("replaces_adjustment_id", value); } } /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. + /// The phase to replace this adjustment from. /// - public string? ReferenceID + public long? PlanPhaseOrder { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("reference_id"); + return this._rawData.GetNullableStruct("plan_phase_order"); } - init { this._rawData.Set("reference_id", value); } + init { this._rawData.Set("plan_phase_order", value); } } /// public override void Validate() { - this.Cadence.Validate(); - this.EventOutputConfig.Validate(); - _ = this.ItemID; - if ( - !JsonElement.DeepEquals( - this.ModelType, - JsonSerializer.SerializeToElement("event_output") - ) - ) - { - throw new OrbInvalidDataException("Invalid value given for constant"); - } - _ = this.Name; - _ = this.BillableMetricID; - _ = this.BilledInAdvance; - this.BillingCycleConfiguration?.Validate(); - _ = this.ConversionRate; - this.ConversionRateConfig?.Validate(); - _ = this.Currency; - this.DimensionalPriceConfiguration?.Validate(); - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.InvoiceGroupingKey; - this.InvoicingCycleConfiguration?.Validate(); - _ = this.Metadata; - _ = this.ReferenceID; + this.Adjustment.Validate(); + _ = this.ReplacesAdjustmentID; + _ = this.PlanPhaseOrder; } - public EventOutput() - { - this.ModelType = JsonSerializer.SerializeToElement("event_output"); - } + public ReplaceAdjustment() { } - public EventOutput(global::Orb.Models.Beta.EventOutput eventOutput) - : base(eventOutput) { } + public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) + : base(replaceAdjustment) { } - public EventOutput(IReadOnlyDictionary rawData) + public ReplaceAdjustment(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("event_output"); } #pragma warning disable CS8618 [SetsRequiredMembers] - EventOutput(FrozenDictionary rawData) + ReplaceAdjustment(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.EventOutput FromRawUnchecked( + /// + public static ReplaceAdjustment FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8905,256 +8550,199 @@ IReadOnlyDictionary rawData } } -class EventOutputFromRaw : IFromRawJson +class ReplaceAdjustmentFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.EventOutput FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.EventOutput.FromRawUnchecked(rawData); + public ReplaceAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => + ReplaceAdjustment.FromRawUnchecked(rawData); } /// -/// The cadence to bill for this price on. +/// The definition of a new adjustment to create and add to the plan. /// -[JsonConverter(typeof(global::Orb.Models.Beta.EventOutputCadenceConverter))] -public enum EventOutputCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class EventOutputCadenceConverter : JsonConverter +[JsonConverter(typeof(ReplaceAdjustmentAdjustmentConverter))] +public record class ReplaceAdjustmentAdjustment : ModelBase { - public override global::Orb.Models.Beta.EventOutputCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => global::Orb.Models.Beta.EventOutputCadence.Annual, - "semi_annual" => global::Orb.Models.Beta.EventOutputCadence.SemiAnnual, - "monthly" => global::Orb.Models.Beta.EventOutputCadence.Monthly, - "quarterly" => global::Orb.Models.Beta.EventOutputCadence.Quarterly, - "one_time" => global::Orb.Models.Beta.EventOutputCadence.OneTime, - "custom" => global::Orb.Models.Beta.EventOutputCadence.Custom, - _ => (global::Orb.Models.Beta.EventOutputCadence)(-1), - }; - } + public object? Value { get; } = null; - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.EventOutputCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - global::Orb.Models.Beta.EventOutputCadence.Annual => "annual", - global::Orb.Models.Beta.EventOutputCadence.SemiAnnual => "semi_annual", - global::Orb.Models.Beta.EventOutputCadence.Monthly => "monthly", - global::Orb.Models.Beta.EventOutputCadence.Quarterly => "quarterly", - global::Orb.Models.Beta.EventOutputCadence.OneTime => "one_time", - global::Orb.Models.Beta.EventOutputCadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} + JsonElement? _element = null; -/// -/// Configuration for event_output pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.EventOutputConfig, - global::Orb.Models.Beta.EventOutputConfigFromRaw - >) -)] -public sealed record class EventOutputConfig : JsonModel -{ - /// - /// The key in the event data to extract the unit rate from. - /// - public required string UnitRatingKey + public JsonElement Json { get { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_rating_key"); + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); } - init { this._rawData.Set("unit_rating_key", value); } } - /// - /// If provided, this amount will be used as the unit rate when an event does - /// not have a value for the `unit_rating_key`. If not provided, events missing - /// a unit rate will be ignored. - /// - public string? DefaultUnitRate + public string? Currency { get { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("default_unit_rate"); + return Match( + newPercentageDiscount: (x) => x.Currency, + newUsageDiscount: (x) => x.Currency, + newAmountDiscount: (x) => x.Currency, + newMinimum: (x) => x.Currency, + newMaximum: (x) => x.Currency + ); } - init { this._rawData.Set("default_unit_rate", value); } } - /// - /// An optional key in the event data to group by (e.g., event ID). All events - /// will also be grouped by their unit rate. - /// - public string? GroupingKey + public bool? IsInvoiceLevel { get { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("grouping_key"); + return Match( + newPercentageDiscount: (x) => x.IsInvoiceLevel, + newUsageDiscount: (x) => x.IsInvoiceLevel, + newAmountDiscount: (x) => x.IsInvoiceLevel, + newMinimum: (x) => x.IsInvoiceLevel, + newMaximum: (x) => x.IsInvoiceLevel + ); } - init { this._rawData.Set("grouping_key", value); } } - /// - public override void Validate() + public ReplaceAdjustmentAdjustment(NewPercentageDiscount value, JsonElement? element = null) { - _ = this.UnitRatingKey; - _ = this.DefaultUnitRate; - _ = this.GroupingKey; + this.Value = value; + this._element = element; } - public EventOutputConfig() { } - - public EventOutputConfig(global::Orb.Models.Beta.EventOutputConfig eventOutputConfig) - : base(eventOutputConfig) { } - - public EventOutputConfig(IReadOnlyDictionary rawData) + public ReplaceAdjustmentAdjustment(NewUsageDiscount value, JsonElement? element = null) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - EventOutputConfig(FrozenDictionary rawData) + public ReplaceAdjustmentAdjustment(NewAmountDiscount value, JsonElement? element = null) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.EventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + public ReplaceAdjustmentAdjustment(NewMinimum value, JsonElement? element = null) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this.Value = value; + this._element = element; } - [SetsRequiredMembers] - public EventOutputConfig(string unitRatingKey) - : this() + public ReplaceAdjustmentAdjustment(NewMaximum value, JsonElement? element = null) { - this.UnitRatingKey = unitRatingKey; + this.Value = value; + this._element = element; } -} - -class EventOutputConfigFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Beta.EventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.EventOutputConfig.FromRawUnchecked(rawData); -} - -[JsonConverter(typeof(global::Orb.Models.Beta.EventOutputConversionRateConfigConverter))] -public record class EventOutputConversionRateConfig : ModelBase -{ - public object? Value { get; } = null; - JsonElement? _element = null; - - public JsonElement Json + public ReplaceAdjustmentAdjustment(JsonElement element) { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } + this._element = element; } - public EventOutputConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPercentageDiscount(out var value)) { + /// // `value` is of type `NewPercentageDiscount` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) { - this.Value = value; - this._element = element; + value = this.Value as NewPercentageDiscount; + return value != null; } - public EventOutputConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewUsageDiscount(out var value)) { + /// // `value` is of type `NewUsageDiscount` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) { - this.Value = value; - this._element = element; + value = this.Value as NewUsageDiscount; + return value != null; } - public EventOutputConversionRateConfig(JsonElement element) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewAmountDiscount(out var value)) { + /// // `value` is of type `NewAmountDiscount` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) { - this._element = element; + value = this.Value as NewAmountDiscount; + return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` + /// if (instance.TryPickNewMinimum(out var value)) { + /// // `value` is of type `NewMinimum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? value) { - value = this.Value as SharedUnitConversionRateConfig; + value = this.Value as NewMinimum; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` + /// if (instance.TryPickNewMaximum(out var value)) { + /// // `value` is of type `NewMaximum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) { - value = this.Value as SharedTieredConversionRateConfig; + value = this.Value as NewMaximum; return value != null; } @@ -9172,28 +8760,43 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// /// public void Switch( - System::Action unit, - System::Action tiered - ) - { - switch (this.Value) + System::Action newPercentageDiscount, + System::Action newUsageDiscount, + System::Action newAmountDiscount, + System::Action newMinimum, + System::Action newMaximum + ) + { + switch (this.Value) { - case SharedUnitConversionRateConfig value: - unit(value); + case NewPercentageDiscount value: + newPercentageDiscount(value); break; - case SharedTieredConversionRateConfig value: - tiered(value); + case NewUsageDiscount value: + newUsageDiscount(value); + break; + case NewAmountDiscount value: + newAmountDiscount(value); + break; + case NewMinimum value: + newMinimum(value); + break; + case NewMaximum value: + newMaximum(value); break; default: throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + "Data did not match any variant of ReplaceAdjustmentAdjustment" ); } } @@ -9213,34 +8816,48 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// /// public T Match( - System::Func unit, - System::Func tiered + System::Func newPercentageDiscount, + System::Func newUsageDiscount, + System::Func newAmountDiscount, + System::Func newMinimum, + System::Func newMaximum ) { return this.Value switch { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), + NewPercentageDiscount value => newPercentageDiscount(value), + NewUsageDiscount value => newUsageDiscount(value), + NewAmountDiscount value => newAmountDiscount(value), + NewMinimum value => newMinimum(value), + NewMaximum value => newMaximum(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + "Data did not match any variant of ReplaceAdjustmentAdjustment" ), }; } - public static implicit operator global::Orb.Models.Beta.EventOutputConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); + public static implicit operator ReplaceAdjustmentAdjustment(NewPercentageDiscount value) => + new(value); - public static implicit operator global::Orb.Models.Beta.EventOutputConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); + public static implicit operator ReplaceAdjustmentAdjustment(NewUsageDiscount value) => + new(value); + + public static implicit operator ReplaceAdjustmentAdjustment(NewAmountDiscount value) => + new(value); + + public static implicit operator ReplaceAdjustmentAdjustment(NewMinimum value) => new(value); + + public static implicit operator ReplaceAdjustmentAdjustment(NewMaximum value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -9257,13 +8874,19 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + "Data did not match any variant of ReplaceAdjustmentAdjustment" ); } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + this.Switch( + (newPercentageDiscount) => newPercentageDiscount.Validate(), + (newUsageDiscount) => newUsageDiscount.Validate(), + (newAmountDiscount) => newAmountDiscount.Validate(), + (newMinimum) => newMinimum.Validate(), + (newMaximum) => newMaximum.Validate() + ); } - public virtual bool Equals(global::Orb.Models.Beta.EventOutputConversionRateConfig? other) + public virtual bool Equals(ReplaceAdjustmentAdjustment? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -9277,33 +8900,32 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class EventOutputConversionRateConfigConverter - : JsonConverter +sealed class ReplaceAdjustmentAdjustmentConverter : JsonConverter { - public override global::Orb.Models.Beta.EventOutputConversionRateConfig? Read( + public override ReplaceAdjustmentAdjustment? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options ) { var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; + string? adjustmentType; try { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); + adjustmentType = element.GetProperty("adjustment_type").GetString(); } catch { - conversionRateType = null; + adjustmentType = null; } - switch (conversionRateType) + switch (adjustmentType) { - case "unit": + case "percentage_discount": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -9321,11 +8943,33 @@ JsonSerializerOptions options return new(element); } - case "tiered": + case "usage_discount": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } + + return new(element); + } + case "amount_discount": + { + try + { + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -9343,16 +8987,54 @@ JsonSerializerOptions options return new(element); } + case "minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } + + return new(element); + } + case "maximum": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } + + return new(element); + } default: { - return new global::Orb.Models.Beta.EventOutputConversionRateConfig(element); + return new ReplaceAdjustmentAdjustment(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.EventOutputConversionRateConfig value, + ReplaceAdjustmentAdjustment value, JsonSerializerOptions options ) { @@ -9360,24 +9042,37 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class RemoveAdjustment : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ReplacePrice : JsonModel { /// - /// The id of the adjustment to remove from on the plan. + /// The id of the price on the plan to replace in the plan. /// - public required string AdjustmentID + public required string ReplacesPriceID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment_id"); + return this._rawData.GetNotNullClass("replaces_price_id"); } - init { this._rawData.Set("adjustment_id", value); } + init { this._rawData.Set("replaces_price_id", value); } } /// - /// The phase to remove this adjustment from. + /// The allocation price to add to the plan. + /// + public NewAllocationPrice? AllocationPrice + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("allocation_price"); + } + init { this._rawData.Set("allocation_price", value); } + } + + /// + /// The phase to replace this price from. /// public long? PlanPhaseOrder { @@ -9389,230 +9084,324 @@ public long? PlanPhaseOrder init { this._rawData.Set("plan_phase_order", value); } } + /// + /// New plan price request body params. + /// + public ReplacePricePrice? Price + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("price"); + } + init { this._rawData.Set("price", value); } + } + /// public override void Validate() { - _ = this.AdjustmentID; + _ = this.ReplacesPriceID; + this.AllocationPrice?.Validate(); _ = this.PlanPhaseOrder; + this.Price?.Validate(); } - public RemoveAdjustment() { } + public ReplacePrice() { } - public RemoveAdjustment(RemoveAdjustment removeAdjustment) - : base(removeAdjustment) { } + public ReplacePrice(ReplacePrice replacePrice) + : base(replacePrice) { } - public RemoveAdjustment(IReadOnlyDictionary rawData) + public ReplacePrice(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - RemoveAdjustment(FrozenDictionary rawData) + ReplacePrice(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static RemoveAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } [SetsRequiredMembers] - public RemoveAdjustment(string adjustmentID) + public ReplacePrice(string replacesPriceID) : this() { - this.AdjustmentID = adjustmentID; + this.ReplacesPriceID = replacesPriceID; } } -class RemoveAdjustmentFromRaw : IFromRawJson +class ReplacePriceFromRaw : IFromRawJson { /// - public RemoveAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => - RemoveAdjustment.FromRawUnchecked(rawData); + public ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) => + ReplacePrice.FromRawUnchecked(rawData); } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class RemovePrice : JsonModel +/// +/// New plan price request body params. +/// +[JsonConverter(typeof(ReplacePricePriceConverter))] +public record class ReplacePricePrice : ModelBase { - /// - /// The id of the price to remove from the plan. - /// - public required string PriceID + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json { get { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("price_id"); + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); } - init { this._rawData.Set("price_id", value); } } - /// - /// The phase to remove this price from. - /// - public long? PlanPhaseOrder + public string ItemID { get { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); + return Match( + newPlanUnit: (x) => x.ItemID, + newPlanTiered: (x) => x.ItemID, + newPlanBulk: (x) => x.ItemID, + bulkWithFilters: (x) => x.ItemID, + newPlanPackage: (x) => x.ItemID, + newPlanMatrix: (x) => x.ItemID, + newPlanThresholdTotalAmount: (x) => x.ItemID, + newPlanTieredPackage: (x) => x.ItemID, + newPlanTieredWithMinimum: (x) => x.ItemID, + newPlanGroupedTiered: (x) => x.ItemID, + newPlanTieredPackageWithMinimum: (x) => x.ItemID, + newPlanPackageWithAllocation: (x) => x.ItemID, + newPlanUnitWithPercent: (x) => x.ItemID, + newPlanMatrixWithAllocation: (x) => x.ItemID, + tieredWithProration: (x) => x.ItemID, + newPlanUnitWithProration: (x) => x.ItemID, + newPlanGroupedAllocation: (x) => x.ItemID, + newPlanBulkWithProration: (x) => x.ItemID, + newPlanGroupedWithProratedMinimum: (x) => x.ItemID, + newPlanGroupedWithMeteredMinimum: (x) => x.ItemID, + groupedWithMinMaxThresholds: (x) => x.ItemID, + newPlanMatrixWithDisplayName: (x) => x.ItemID, + newPlanGroupedTieredPackage: (x) => x.ItemID, + newPlanMaxGroupTieredPackage: (x) => x.ItemID, + newPlanScalableMatrixWithUnitPricing: (x) => x.ItemID, + newPlanScalableMatrixWithTieredPricing: (x) => x.ItemID, + newPlanCumulativeGroupedBulk: (x) => x.ItemID, + cumulativeGroupedAllocation: (x) => x.ItemID, + newPlanMinimumComposite: (x) => x.ItemID, + percent: (x) => x.ItemID, + eventOutput: (x) => x.ItemID + ); } - init { this._rawData.Set("plan_phase_order", value); } - } - - /// - public override void Validate() - { - _ = this.PriceID; - _ = this.PlanPhaseOrder; - } - - public RemovePrice() { } - - public RemovePrice(RemovePrice removePrice) - : base(removePrice) { } - - public RemovePrice(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemovePrice(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public RemovePrice(string priceID) - : this() - { - this.PriceID = priceID; } -} - -class RemovePriceFromRaw : IFromRawJson -{ - /// - public RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) => - RemovePrice.FromRawUnchecked(rawData); -} -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class ReplaceAdjustment : JsonModel -{ - /// - /// The definition of a new adjustment to create and add to the plan. - /// - public required ReplaceAdjustmentAdjustment Adjustment + public string Name { get { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment"); + return Match( + newPlanUnit: (x) => x.Name, + newPlanTiered: (x) => x.Name, + newPlanBulk: (x) => x.Name, + bulkWithFilters: (x) => x.Name, + newPlanPackage: (x) => x.Name, + newPlanMatrix: (x) => x.Name, + newPlanThresholdTotalAmount: (x) => x.Name, + newPlanTieredPackage: (x) => x.Name, + newPlanTieredWithMinimum: (x) => x.Name, + newPlanGroupedTiered: (x) => x.Name, + newPlanTieredPackageWithMinimum: (x) => x.Name, + newPlanPackageWithAllocation: (x) => x.Name, + newPlanUnitWithPercent: (x) => x.Name, + newPlanMatrixWithAllocation: (x) => x.Name, + tieredWithProration: (x) => x.Name, + newPlanUnitWithProration: (x) => x.Name, + newPlanGroupedAllocation: (x) => x.Name, + newPlanBulkWithProration: (x) => x.Name, + newPlanGroupedWithProratedMinimum: (x) => x.Name, + newPlanGroupedWithMeteredMinimum: (x) => x.Name, + groupedWithMinMaxThresholds: (x) => x.Name, + newPlanMatrixWithDisplayName: (x) => x.Name, + newPlanGroupedTieredPackage: (x) => x.Name, + newPlanMaxGroupTieredPackage: (x) => x.Name, + newPlanScalableMatrixWithUnitPricing: (x) => x.Name, + newPlanScalableMatrixWithTieredPricing: (x) => x.Name, + newPlanCumulativeGroupedBulk: (x) => x.Name, + cumulativeGroupedAllocation: (x) => x.Name, + newPlanMinimumComposite: (x) => x.Name, + percent: (x) => x.Name, + eventOutput: (x) => x.Name + ); } - init { this._rawData.Set("adjustment", value); } } - /// - /// The id of the adjustment on the plan to replace in the plan. - /// - public required string ReplacesAdjustmentID + public string? BillableMetricID { get { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_adjustment_id"); + return Match( + newPlanUnit: (x) => x.BillableMetricID, + newPlanTiered: (x) => x.BillableMetricID, + newPlanBulk: (x) => x.BillableMetricID, + bulkWithFilters: (x) => x.BillableMetricID, + newPlanPackage: (x) => x.BillableMetricID, + newPlanMatrix: (x) => x.BillableMetricID, + newPlanThresholdTotalAmount: (x) => x.BillableMetricID, + newPlanTieredPackage: (x) => x.BillableMetricID, + newPlanTieredWithMinimum: (x) => x.BillableMetricID, + newPlanGroupedTiered: (x) => x.BillableMetricID, + newPlanTieredPackageWithMinimum: (x) => x.BillableMetricID, + newPlanPackageWithAllocation: (x) => x.BillableMetricID, + newPlanUnitWithPercent: (x) => x.BillableMetricID, + newPlanMatrixWithAllocation: (x) => x.BillableMetricID, + tieredWithProration: (x) => x.BillableMetricID, + newPlanUnitWithProration: (x) => x.BillableMetricID, + newPlanGroupedAllocation: (x) => x.BillableMetricID, + newPlanBulkWithProration: (x) => x.BillableMetricID, + newPlanGroupedWithProratedMinimum: (x) => x.BillableMetricID, + newPlanGroupedWithMeteredMinimum: (x) => x.BillableMetricID, + groupedWithMinMaxThresholds: (x) => x.BillableMetricID, + newPlanMatrixWithDisplayName: (x) => x.BillableMetricID, + newPlanGroupedTieredPackage: (x) => x.BillableMetricID, + newPlanMaxGroupTieredPackage: (x) => x.BillableMetricID, + newPlanScalableMatrixWithUnitPricing: (x) => x.BillableMetricID, + newPlanScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, + newPlanCumulativeGroupedBulk: (x) => x.BillableMetricID, + cumulativeGroupedAllocation: (x) => x.BillableMetricID, + newPlanMinimumComposite: (x) => x.BillableMetricID, + percent: (x) => x.BillableMetricID, + eventOutput: (x) => x.BillableMetricID + ); } - init { this._rawData.Set("replaces_adjustment_id", value); } } - /// - /// The phase to replace this adjustment from. - /// - public long? PlanPhaseOrder + public bool? BilledInAdvance { get { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); + return Match( + newPlanUnit: (x) => x.BilledInAdvance, + newPlanTiered: (x) => x.BilledInAdvance, + newPlanBulk: (x) => x.BilledInAdvance, + bulkWithFilters: (x) => x.BilledInAdvance, + newPlanPackage: (x) => x.BilledInAdvance, + newPlanMatrix: (x) => x.BilledInAdvance, + newPlanThresholdTotalAmount: (x) => x.BilledInAdvance, + newPlanTieredPackage: (x) => x.BilledInAdvance, + newPlanTieredWithMinimum: (x) => x.BilledInAdvance, + newPlanGroupedTiered: (x) => x.BilledInAdvance, + newPlanTieredPackageWithMinimum: (x) => x.BilledInAdvance, + newPlanPackageWithAllocation: (x) => x.BilledInAdvance, + newPlanUnitWithPercent: (x) => x.BilledInAdvance, + newPlanMatrixWithAllocation: (x) => x.BilledInAdvance, + tieredWithProration: (x) => x.BilledInAdvance, + newPlanUnitWithProration: (x) => x.BilledInAdvance, + newPlanGroupedAllocation: (x) => x.BilledInAdvance, + newPlanBulkWithProration: (x) => x.BilledInAdvance, + newPlanGroupedWithProratedMinimum: (x) => x.BilledInAdvance, + newPlanGroupedWithMeteredMinimum: (x) => x.BilledInAdvance, + groupedWithMinMaxThresholds: (x) => x.BilledInAdvance, + newPlanMatrixWithDisplayName: (x) => x.BilledInAdvance, + newPlanGroupedTieredPackage: (x) => x.BilledInAdvance, + newPlanMaxGroupTieredPackage: (x) => x.BilledInAdvance, + newPlanScalableMatrixWithUnitPricing: (x) => x.BilledInAdvance, + newPlanScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, + newPlanCumulativeGroupedBulk: (x) => x.BilledInAdvance, + cumulativeGroupedAllocation: (x) => x.BilledInAdvance, + newPlanMinimumComposite: (x) => x.BilledInAdvance, + percent: (x) => x.BilledInAdvance, + eventOutput: (x) => x.BilledInAdvance + ); } - init { this._rawData.Set("plan_phase_order", value); } } - /// - public override void Validate() + public NewBillingCycleConfiguration? BillingCycleConfiguration { - this.Adjustment.Validate(); - _ = this.ReplacesAdjustmentID; - _ = this.PlanPhaseOrder; + get + { + return Match( + newPlanUnit: (x) => x.BillingCycleConfiguration, + newPlanTiered: (x) => x.BillingCycleConfiguration, + newPlanBulk: (x) => x.BillingCycleConfiguration, + bulkWithFilters: (x) => x.BillingCycleConfiguration, + newPlanPackage: (x) => x.BillingCycleConfiguration, + newPlanMatrix: (x) => x.BillingCycleConfiguration, + newPlanThresholdTotalAmount: (x) => x.BillingCycleConfiguration, + newPlanTieredPackage: (x) => x.BillingCycleConfiguration, + newPlanTieredWithMinimum: (x) => x.BillingCycleConfiguration, + newPlanGroupedTiered: (x) => x.BillingCycleConfiguration, + newPlanTieredPackageWithMinimum: (x) => x.BillingCycleConfiguration, + newPlanPackageWithAllocation: (x) => x.BillingCycleConfiguration, + newPlanUnitWithPercent: (x) => x.BillingCycleConfiguration, + newPlanMatrixWithAllocation: (x) => x.BillingCycleConfiguration, + tieredWithProration: (x) => x.BillingCycleConfiguration, + newPlanUnitWithProration: (x) => x.BillingCycleConfiguration, + newPlanGroupedAllocation: (x) => x.BillingCycleConfiguration, + newPlanBulkWithProration: (x) => x.BillingCycleConfiguration, + newPlanGroupedWithProratedMinimum: (x) => x.BillingCycleConfiguration, + newPlanGroupedWithMeteredMinimum: (x) => x.BillingCycleConfiguration, + groupedWithMinMaxThresholds: (x) => x.BillingCycleConfiguration, + newPlanMatrixWithDisplayName: (x) => x.BillingCycleConfiguration, + newPlanGroupedTieredPackage: (x) => x.BillingCycleConfiguration, + newPlanMaxGroupTieredPackage: (x) => x.BillingCycleConfiguration, + newPlanScalableMatrixWithUnitPricing: (x) => x.BillingCycleConfiguration, + newPlanScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, + newPlanCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, + cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, + newPlanMinimumComposite: (x) => x.BillingCycleConfiguration, + percent: (x) => x.BillingCycleConfiguration, + eventOutput: (x) => x.BillingCycleConfiguration + ); + } } - public ReplaceAdjustment() { } - - public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) - : base(replaceAdjustment) { } - - public ReplaceAdjustment(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplaceAdjustment(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static ReplaceAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class ReplaceAdjustmentFromRaw : IFromRawJson -{ - /// - public ReplaceAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => - ReplaceAdjustment.FromRawUnchecked(rawData); -} - -/// -/// The definition of a new adjustment to create and add to the plan. -/// -[JsonConverter(typeof(ReplaceAdjustmentAdjustmentConverter))] -public record class ReplaceAdjustmentAdjustment : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - - public JsonElement Json + public double? ConversionRate { get { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions + return Match( + newPlanUnit: (x) => x.ConversionRate, + newPlanTiered: (x) => x.ConversionRate, + newPlanBulk: (x) => x.ConversionRate, + bulkWithFilters: (x) => x.ConversionRate, + newPlanPackage: (x) => x.ConversionRate, + newPlanMatrix: (x) => x.ConversionRate, + newPlanThresholdTotalAmount: (x) => x.ConversionRate, + newPlanTieredPackage: (x) => x.ConversionRate, + newPlanTieredWithMinimum: (x) => x.ConversionRate, + newPlanGroupedTiered: (x) => x.ConversionRate, + newPlanTieredPackageWithMinimum: (x) => x.ConversionRate, + newPlanPackageWithAllocation: (x) => x.ConversionRate, + newPlanUnitWithPercent: (x) => x.ConversionRate, + newPlanMatrixWithAllocation: (x) => x.ConversionRate, + tieredWithProration: (x) => x.ConversionRate, + newPlanUnitWithProration: (x) => x.ConversionRate, + newPlanGroupedAllocation: (x) => x.ConversionRate, + newPlanBulkWithProration: (x) => x.ConversionRate, + newPlanGroupedWithProratedMinimum: (x) => x.ConversionRate, + newPlanGroupedWithMeteredMinimum: (x) => x.ConversionRate, + groupedWithMinMaxThresholds: (x) => x.ConversionRate, + newPlanMatrixWithDisplayName: (x) => x.ConversionRate, + newPlanGroupedTieredPackage: (x) => x.ConversionRate, + newPlanMaxGroupTieredPackage: (x) => x.ConversionRate, + newPlanScalableMatrixWithUnitPricing: (x) => x.ConversionRate, + newPlanScalableMatrixWithTieredPricing: (x) => x.ConversionRate, + newPlanCumulativeGroupedBulk: (x) => x.ConversionRate, + cumulativeGroupedAllocation: (x) => x.ConversionRate, + newPlanMinimumComposite: (x) => x.ConversionRate, + percent: (x) => x.ConversionRate, + eventOutput: (x) => x.ConversionRate ); } } @@ -9622,4227 +9411,2356 @@ public string? Currency get { return Match( - newPercentageDiscount: (x) => x.Currency, - newUsageDiscount: (x) => x.Currency, - newAmountDiscount: (x) => x.Currency, - newMinimum: (x) => x.Currency, - newMaximum: (x) => x.Currency + newPlanUnit: (x) => x.Currency, + newPlanTiered: (x) => x.Currency, + newPlanBulk: (x) => x.Currency, + bulkWithFilters: (x) => x.Currency, + newPlanPackage: (x) => x.Currency, + newPlanMatrix: (x) => x.Currency, + newPlanThresholdTotalAmount: (x) => x.Currency, + newPlanTieredPackage: (x) => x.Currency, + newPlanTieredWithMinimum: (x) => x.Currency, + newPlanGroupedTiered: (x) => x.Currency, + newPlanTieredPackageWithMinimum: (x) => x.Currency, + newPlanPackageWithAllocation: (x) => x.Currency, + newPlanUnitWithPercent: (x) => x.Currency, + newPlanMatrixWithAllocation: (x) => x.Currency, + tieredWithProration: (x) => x.Currency, + newPlanUnitWithProration: (x) => x.Currency, + newPlanGroupedAllocation: (x) => x.Currency, + newPlanBulkWithProration: (x) => x.Currency, + newPlanGroupedWithProratedMinimum: (x) => x.Currency, + newPlanGroupedWithMeteredMinimum: (x) => x.Currency, + groupedWithMinMaxThresholds: (x) => x.Currency, + newPlanMatrixWithDisplayName: (x) => x.Currency, + newPlanGroupedTieredPackage: (x) => x.Currency, + newPlanMaxGroupTieredPackage: (x) => x.Currency, + newPlanScalableMatrixWithUnitPricing: (x) => x.Currency, + newPlanScalableMatrixWithTieredPricing: (x) => x.Currency, + newPlanCumulativeGroupedBulk: (x) => x.Currency, + cumulativeGroupedAllocation: (x) => x.Currency, + newPlanMinimumComposite: (x) => x.Currency, + percent: (x) => x.Currency, + eventOutput: (x) => x.Currency ); } } - public bool? IsInvoiceLevel + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { get { - return Match( - newPercentageDiscount: (x) => x.IsInvoiceLevel, - newUsageDiscount: (x) => x.IsInvoiceLevel, - newAmountDiscount: (x) => x.IsInvoiceLevel, - newMinimum: (x) => x.IsInvoiceLevel, - newMaximum: (x) => x.IsInvoiceLevel + return Match( + newPlanUnit: (x) => x.DimensionalPriceConfiguration, + newPlanTiered: (x) => x.DimensionalPriceConfiguration, + newPlanBulk: (x) => x.DimensionalPriceConfiguration, + bulkWithFilters: (x) => x.DimensionalPriceConfiguration, + newPlanPackage: (x) => x.DimensionalPriceConfiguration, + newPlanMatrix: (x) => x.DimensionalPriceConfiguration, + newPlanThresholdTotalAmount: (x) => x.DimensionalPriceConfiguration, + newPlanTieredPackage: (x) => x.DimensionalPriceConfiguration, + newPlanTieredWithMinimum: (x) => x.DimensionalPriceConfiguration, + newPlanGroupedTiered: (x) => x.DimensionalPriceConfiguration, + newPlanTieredPackageWithMinimum: (x) => x.DimensionalPriceConfiguration, + newPlanPackageWithAllocation: (x) => x.DimensionalPriceConfiguration, + newPlanUnitWithPercent: (x) => x.DimensionalPriceConfiguration, + newPlanMatrixWithAllocation: (x) => x.DimensionalPriceConfiguration, + tieredWithProration: (x) => x.DimensionalPriceConfiguration, + newPlanUnitWithProration: (x) => x.DimensionalPriceConfiguration, + newPlanGroupedAllocation: (x) => x.DimensionalPriceConfiguration, + newPlanBulkWithProration: (x) => x.DimensionalPriceConfiguration, + newPlanGroupedWithProratedMinimum: (x) => x.DimensionalPriceConfiguration, + newPlanGroupedWithMeteredMinimum: (x) => x.DimensionalPriceConfiguration, + groupedWithMinMaxThresholds: (x) => x.DimensionalPriceConfiguration, + newPlanMatrixWithDisplayName: (x) => x.DimensionalPriceConfiguration, + newPlanGroupedTieredPackage: (x) => x.DimensionalPriceConfiguration, + newPlanMaxGroupTieredPackage: (x) => x.DimensionalPriceConfiguration, + newPlanScalableMatrixWithUnitPricing: (x) => x.DimensionalPriceConfiguration, + newPlanScalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, + newPlanCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, + cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, + newPlanMinimumComposite: (x) => x.DimensionalPriceConfiguration, + percent: (x) => x.DimensionalPriceConfiguration, + eventOutput: (x) => x.DimensionalPriceConfiguration ); } } - public ReplaceAdjustmentAdjustment(NewPercentageDiscount value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplaceAdjustmentAdjustment(NewUsageDiscount value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplaceAdjustmentAdjustment(NewAmountDiscount value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplaceAdjustmentAdjustment(NewMinimum value, JsonElement? element = null) + public string? ExternalPriceID { - this.Value = value; - this._element = element; + get + { + return Match( + newPlanUnit: (x) => x.ExternalPriceID, + newPlanTiered: (x) => x.ExternalPriceID, + newPlanBulk: (x) => x.ExternalPriceID, + bulkWithFilters: (x) => x.ExternalPriceID, + newPlanPackage: (x) => x.ExternalPriceID, + newPlanMatrix: (x) => x.ExternalPriceID, + newPlanThresholdTotalAmount: (x) => x.ExternalPriceID, + newPlanTieredPackage: (x) => x.ExternalPriceID, + newPlanTieredWithMinimum: (x) => x.ExternalPriceID, + newPlanGroupedTiered: (x) => x.ExternalPriceID, + newPlanTieredPackageWithMinimum: (x) => x.ExternalPriceID, + newPlanPackageWithAllocation: (x) => x.ExternalPriceID, + newPlanUnitWithPercent: (x) => x.ExternalPriceID, + newPlanMatrixWithAllocation: (x) => x.ExternalPriceID, + tieredWithProration: (x) => x.ExternalPriceID, + newPlanUnitWithProration: (x) => x.ExternalPriceID, + newPlanGroupedAllocation: (x) => x.ExternalPriceID, + newPlanBulkWithProration: (x) => x.ExternalPriceID, + newPlanGroupedWithProratedMinimum: (x) => x.ExternalPriceID, + newPlanGroupedWithMeteredMinimum: (x) => x.ExternalPriceID, + groupedWithMinMaxThresholds: (x) => x.ExternalPriceID, + newPlanMatrixWithDisplayName: (x) => x.ExternalPriceID, + newPlanGroupedTieredPackage: (x) => x.ExternalPriceID, + newPlanMaxGroupTieredPackage: (x) => x.ExternalPriceID, + newPlanScalableMatrixWithUnitPricing: (x) => x.ExternalPriceID, + newPlanScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, + newPlanCumulativeGroupedBulk: (x) => x.ExternalPriceID, + cumulativeGroupedAllocation: (x) => x.ExternalPriceID, + newPlanMinimumComposite: (x) => x.ExternalPriceID, + percent: (x) => x.ExternalPriceID, + eventOutput: (x) => x.ExternalPriceID + ); + } } - public ReplaceAdjustmentAdjustment(NewMaximum value, JsonElement? element = null) + public double? FixedPriceQuantity { - this.Value = value; - this._element = element; + get + { + return Match( + newPlanUnit: (x) => x.FixedPriceQuantity, + newPlanTiered: (x) => x.FixedPriceQuantity, + newPlanBulk: (x) => x.FixedPriceQuantity, + bulkWithFilters: (x) => x.FixedPriceQuantity, + newPlanPackage: (x) => x.FixedPriceQuantity, + newPlanMatrix: (x) => x.FixedPriceQuantity, + newPlanThresholdTotalAmount: (x) => x.FixedPriceQuantity, + newPlanTieredPackage: (x) => x.FixedPriceQuantity, + newPlanTieredWithMinimum: (x) => x.FixedPriceQuantity, + newPlanGroupedTiered: (x) => x.FixedPriceQuantity, + newPlanTieredPackageWithMinimum: (x) => x.FixedPriceQuantity, + newPlanPackageWithAllocation: (x) => x.FixedPriceQuantity, + newPlanUnitWithPercent: (x) => x.FixedPriceQuantity, + newPlanMatrixWithAllocation: (x) => x.FixedPriceQuantity, + tieredWithProration: (x) => x.FixedPriceQuantity, + newPlanUnitWithProration: (x) => x.FixedPriceQuantity, + newPlanGroupedAllocation: (x) => x.FixedPriceQuantity, + newPlanBulkWithProration: (x) => x.FixedPriceQuantity, + newPlanGroupedWithProratedMinimum: (x) => x.FixedPriceQuantity, + newPlanGroupedWithMeteredMinimum: (x) => x.FixedPriceQuantity, + groupedWithMinMaxThresholds: (x) => x.FixedPriceQuantity, + newPlanMatrixWithDisplayName: (x) => x.FixedPriceQuantity, + newPlanGroupedTieredPackage: (x) => x.FixedPriceQuantity, + newPlanMaxGroupTieredPackage: (x) => x.FixedPriceQuantity, + newPlanScalableMatrixWithUnitPricing: (x) => x.FixedPriceQuantity, + newPlanScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, + newPlanCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, + cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, + newPlanMinimumComposite: (x) => x.FixedPriceQuantity, + percent: (x) => x.FixedPriceQuantity, + eventOutput: (x) => x.FixedPriceQuantity + ); + } } - public ReplaceAdjustmentAdjustment(JsonElement element) + public string? InvoiceGroupingKey { - this._element = element; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPercentageDiscount(out var value)) { - /// // `value` is of type `NewPercentageDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) + get + { + return Match( + newPlanUnit: (x) => x.InvoiceGroupingKey, + newPlanTiered: (x) => x.InvoiceGroupingKey, + newPlanBulk: (x) => x.InvoiceGroupingKey, + bulkWithFilters: (x) => x.InvoiceGroupingKey, + newPlanPackage: (x) => x.InvoiceGroupingKey, + newPlanMatrix: (x) => x.InvoiceGroupingKey, + newPlanThresholdTotalAmount: (x) => x.InvoiceGroupingKey, + newPlanTieredPackage: (x) => x.InvoiceGroupingKey, + newPlanTieredWithMinimum: (x) => x.InvoiceGroupingKey, + newPlanGroupedTiered: (x) => x.InvoiceGroupingKey, + newPlanTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, + newPlanPackageWithAllocation: (x) => x.InvoiceGroupingKey, + newPlanUnitWithPercent: (x) => x.InvoiceGroupingKey, + newPlanMatrixWithAllocation: (x) => x.InvoiceGroupingKey, + tieredWithProration: (x) => x.InvoiceGroupingKey, + newPlanUnitWithProration: (x) => x.InvoiceGroupingKey, + newPlanGroupedAllocation: (x) => x.InvoiceGroupingKey, + newPlanBulkWithProration: (x) => x.InvoiceGroupingKey, + newPlanGroupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, + newPlanGroupedWithMeteredMinimum: (x) => x.InvoiceGroupingKey, + groupedWithMinMaxThresholds: (x) => x.InvoiceGroupingKey, + newPlanMatrixWithDisplayName: (x) => x.InvoiceGroupingKey, + newPlanGroupedTieredPackage: (x) => x.InvoiceGroupingKey, + newPlanMaxGroupTieredPackage: (x) => x.InvoiceGroupingKey, + newPlanScalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, + newPlanScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, + newPlanCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, + cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, + newPlanMinimumComposite: (x) => x.InvoiceGroupingKey, + percent: (x) => x.InvoiceGroupingKey, + eventOutput: (x) => x.InvoiceGroupingKey + ); + } + } + + public NewBillingCycleConfiguration? InvoicingCycleConfiguration { - value = this.Value as NewPercentageDiscount; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.InvoicingCycleConfiguration, + newPlanTiered: (x) => x.InvoicingCycleConfiguration, + newPlanBulk: (x) => x.InvoicingCycleConfiguration, + bulkWithFilters: (x) => x.InvoicingCycleConfiguration, + newPlanPackage: (x) => x.InvoicingCycleConfiguration, + newPlanMatrix: (x) => x.InvoicingCycleConfiguration, + newPlanThresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, + newPlanTieredPackage: (x) => x.InvoicingCycleConfiguration, + newPlanTieredWithMinimum: (x) => x.InvoicingCycleConfiguration, + newPlanGroupedTiered: (x) => x.InvoicingCycleConfiguration, + newPlanTieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, + newPlanPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, + newPlanUnitWithPercent: (x) => x.InvoicingCycleConfiguration, + newPlanMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, + tieredWithProration: (x) => x.InvoicingCycleConfiguration, + newPlanUnitWithProration: (x) => x.InvoicingCycleConfiguration, + newPlanGroupedAllocation: (x) => x.InvoicingCycleConfiguration, + newPlanBulkWithProration: (x) => x.InvoicingCycleConfiguration, + newPlanGroupedWithProratedMinimum: (x) => x.InvoicingCycleConfiguration, + newPlanGroupedWithMeteredMinimum: (x) => x.InvoicingCycleConfiguration, + groupedWithMinMaxThresholds: (x) => x.InvoicingCycleConfiguration, + newPlanMatrixWithDisplayName: (x) => x.InvoicingCycleConfiguration, + newPlanGroupedTieredPackage: (x) => x.InvoicingCycleConfiguration, + newPlanMaxGroupTieredPackage: (x) => x.InvoicingCycleConfiguration, + newPlanScalableMatrixWithUnitPricing: (x) => x.InvoicingCycleConfiguration, + newPlanScalableMatrixWithTieredPricing: (x) => x.InvoicingCycleConfiguration, + newPlanCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, + cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, + newPlanMinimumComposite: (x) => x.InvoicingCycleConfiguration, + percent: (x) => x.InvoicingCycleConfiguration, + eventOutput: (x) => x.InvoicingCycleConfiguration + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewUsageDiscount(out var value)) { - /// // `value` is of type `NewUsageDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) + public string? ReferenceID { - value = this.Value as NewUsageDiscount; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.ReferenceID, + newPlanTiered: (x) => x.ReferenceID, + newPlanBulk: (x) => x.ReferenceID, + bulkWithFilters: (x) => x.ReferenceID, + newPlanPackage: (x) => x.ReferenceID, + newPlanMatrix: (x) => x.ReferenceID, + newPlanThresholdTotalAmount: (x) => x.ReferenceID, + newPlanTieredPackage: (x) => x.ReferenceID, + newPlanTieredWithMinimum: (x) => x.ReferenceID, + newPlanGroupedTiered: (x) => x.ReferenceID, + newPlanTieredPackageWithMinimum: (x) => x.ReferenceID, + newPlanPackageWithAllocation: (x) => x.ReferenceID, + newPlanUnitWithPercent: (x) => x.ReferenceID, + newPlanMatrixWithAllocation: (x) => x.ReferenceID, + tieredWithProration: (x) => x.ReferenceID, + newPlanUnitWithProration: (x) => x.ReferenceID, + newPlanGroupedAllocation: (x) => x.ReferenceID, + newPlanBulkWithProration: (x) => x.ReferenceID, + newPlanGroupedWithProratedMinimum: (x) => x.ReferenceID, + newPlanGroupedWithMeteredMinimum: (x) => x.ReferenceID, + groupedWithMinMaxThresholds: (x) => x.ReferenceID, + newPlanMatrixWithDisplayName: (x) => x.ReferenceID, + newPlanGroupedTieredPackage: (x) => x.ReferenceID, + newPlanMaxGroupTieredPackage: (x) => x.ReferenceID, + newPlanScalableMatrixWithUnitPricing: (x) => x.ReferenceID, + newPlanScalableMatrixWithTieredPricing: (x) => x.ReferenceID, + newPlanCumulativeGroupedBulk: (x) => x.ReferenceID, + cumulativeGroupedAllocation: (x) => x.ReferenceID, + newPlanMinimumComposite: (x) => x.ReferenceID, + percent: (x) => x.ReferenceID, + eventOutput: (x) => x.ReferenceID + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewAmountDiscount(out var value)) { - /// // `value` is of type `NewAmountDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) + public ReplacePricePrice(NewPlanUnitPrice value, JsonElement? element = null) { - value = this.Value as NewAmountDiscount; - return value != null; + this.Value = value; + this._element = element; } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewMinimum(out var value)) { - /// // `value` is of type `NewMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? value) + public ReplacePricePrice(NewPlanTieredPrice value, JsonElement? element = null) { - value = this.Value as NewMinimum; - return value != null; + this.Value = value; + this._element = element; } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewMaximum(out var value)) { - /// // `value` is of type `NewMaximum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) + public ReplacePricePrice(NewPlanBulkPrice value, JsonElement? element = null) { - value = this.Value as NewMaximum; - return value != null; + this.Value = value; + this._element = element; } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action newPercentageDiscount, - System::Action newUsageDiscount, - System::Action newAmountDiscount, - System::Action newMinimum, - System::Action newMaximum - ) + public ReplacePricePrice(ReplacePricePriceBulkWithFilters value, JsonElement? element = null) { - switch (this.Value) - { - case NewPercentageDiscount value: - newPercentageDiscount(value); - break; - case NewUsageDiscount value: - newUsageDiscount(value); - break; - case NewAmountDiscount value: - newAmountDiscount(value); - break; - case NewMinimum value: - newMinimum(value); - break; - case NewMaximum value: - newMaximum(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of ReplaceAdjustmentAdjustment" - ); - } + this.Value = value; + this._element = element; } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func newPercentageDiscount, - System::Func newUsageDiscount, - System::Func newAmountDiscount, - System::Func newMinimum, - System::Func newMaximum - ) + public ReplacePricePrice(NewPlanPackagePrice value, JsonElement? element = null) { - return this.Value switch - { - NewPercentageDiscount value => newPercentageDiscount(value), - NewUsageDiscount value => newUsageDiscount(value), - NewAmountDiscount value => newAmountDiscount(value), - NewMinimum value => newMinimum(value), - NewMaximum value => newMaximum(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplaceAdjustmentAdjustment" - ), - }; + this.Value = value; + this._element = element; } - public static implicit operator ReplaceAdjustmentAdjustment(NewPercentageDiscount value) => - new(value); + public ReplacePricePrice(NewPlanMatrixPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - public static implicit operator ReplaceAdjustmentAdjustment(NewUsageDiscount value) => - new(value); + public ReplacePricePrice(NewPlanThresholdTotalAmountPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - public static implicit operator ReplaceAdjustmentAdjustment(NewAmountDiscount value) => - new(value); + public ReplacePricePrice(NewPlanTieredPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - public static implicit operator ReplaceAdjustmentAdjustment(NewMinimum value) => new(value); + public ReplacePricePrice(NewPlanTieredWithMinimumPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - public static implicit operator ReplaceAdjustmentAdjustment(NewMaximum value) => new(value); + public ReplacePricePrice(NewPlanGroupedTieredPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() + public ReplacePricePrice( + NewPlanTieredPackageWithMinimumPrice value, + JsonElement? element = null + ) { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of ReplaceAdjustmentAdjustment" - ); - } - this.Switch( - (newPercentageDiscount) => newPercentageDiscount.Validate(), - (newUsageDiscount) => newUsageDiscount.Validate(), - (newAmountDiscount) => newAmountDiscount.Validate(), - (newMinimum) => newMinimum.Validate(), - (newMaximum) => newMaximum.Validate() - ); + this.Value = value; + this._element = element; } - public virtual bool Equals(ReplaceAdjustmentAdjustment? other) + public ReplacePricePrice(NewPlanPackageWithAllocationPrice value, JsonElement? element = null) { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); + this.Value = value; + this._element = element; } - public override int GetHashCode() + public ReplacePricePrice(NewPlanUnitWithPercentPrice value, JsonElement? element = null) { - return 0; + this.Value = value; + this._element = element; } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} + public ReplacePricePrice(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } -sealed class ReplaceAdjustmentAdjustmentConverter : JsonConverter -{ - public override ReplaceAdjustmentAdjustment? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options + public ReplacePricePrice( + ReplacePricePriceTieredWithProration value, + JsonElement? element = null ) { - var element = JsonSerializer.Deserialize(ref reader, options); - string? adjustmentType; - try - { - adjustmentType = element.GetProperty("adjustment_type").GetString(); - } - catch - { - adjustmentType = null; - } - - switch (adjustmentType) - { - case "percentage_discount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + this.Value = value; + this._element = element; + } - return new(element); - } - case "usage_discount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePrice(NewPlanUnitWithProrationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "amount_discount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePrice(NewPlanGroupedAllocationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "minimum": - { - try - { - var deserialized = JsonSerializer.Deserialize(element, options); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePrice(NewPlanBulkWithProrationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "maximum": - { - try - { - var deserialized = JsonSerializer.Deserialize(element, options); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new ReplaceAdjustmentAdjustment(element); - } - } + public ReplacePricePrice( + NewPlanGroupedWithProratedMinimumPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; } - public override void Write( - Utf8JsonWriter writer, - ReplaceAdjustmentAdjustment value, - JsonSerializerOptions options + public ReplacePricePrice( + NewPlanGroupedWithMeteredMinimumPrice value, + JsonElement? element = null ) { - JsonSerializer.Serialize(writer, value.Json, options); + this.Value = value; + this._element = element; } -} -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class ReplacePrice : JsonModel -{ - /// - /// The id of the price on the plan to replace in the plan. - /// - public required string ReplacesPriceID + public ReplacePricePrice( + ReplacePricePriceGroupedWithMinMaxThresholds value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_price_id"); - } - init { this._rawData.Set("replaces_price_id", value); } + this.Value = value; + this._element = element; } - /// - /// The allocation price to add to the plan. - /// - public NewAllocationPrice? AllocationPrice + public ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice value, JsonElement? element = null) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("allocation_price"); - } - init { this._rawData.Set("allocation_price", value); } + this.Value = value; + this._element = element; } - /// - /// The phase to replace this price from. - /// - public long? PlanPhaseOrder + public ReplacePricePrice(NewPlanGroupedTieredPackagePrice value, JsonElement? element = null) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); - } - init { this._rawData.Set("plan_phase_order", value); } + this.Value = value; + this._element = element; } - /// - /// New plan price request body params. - /// - public ReplacePricePrice? Price + public ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("price"); - } - init { this._rawData.Set("price", value); } + this.Value = value; + this._element = element; } - /// - public override void Validate() + public ReplacePricePrice( + NewPlanScalableMatrixWithUnitPricingPrice value, + JsonElement? element = null + ) { - _ = this.ReplacesPriceID; - this.AllocationPrice?.Validate(); - _ = this.PlanPhaseOrder; - this.Price?.Validate(); + this.Value = value; + this._element = element; } - public ReplacePrice() { } - - public ReplacePrice(ReplacePrice replacePrice) - : base(replacePrice) { } - - public ReplacePrice(IReadOnlyDictionary rawData) + public ReplacePricePrice( + NewPlanScalableMatrixWithTieredPricingPrice value, + JsonElement? element = null + ) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePrice(FrozenDictionary rawData) + public ReplacePricePrice(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = null) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning restore CS8618 - /// - public static ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) + public ReplacePricePrice( + ReplacePricePriceCumulativeGroupedAllocation value, + JsonElement? element = null + ) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this.Value = value; + this._element = element; } - [SetsRequiredMembers] - public ReplacePrice(string replacesPriceID) - : this() + public ReplacePricePrice(NewPlanMinimumCompositePrice value, JsonElement? element = null) { - this.ReplacesPriceID = replacesPriceID; + this.Value = value; + this._element = element; } -} - -class ReplacePriceFromRaw : IFromRawJson -{ - /// - public ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) => - ReplacePrice.FromRawUnchecked(rawData); -} - -/// -/// New plan price request body params. -/// -[JsonConverter(typeof(ReplacePricePriceConverter))] -public record class ReplacePricePrice : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - public JsonElement Json + public ReplacePricePrice(ReplacePricePricePercent value, JsonElement? element = null) { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } + this.Value = value; + this._element = element; } - public string ItemID + public ReplacePricePrice(ReplacePricePriceEventOutput value, JsonElement? element = null) { - get - { - return Match( - newPlanUnit: (x) => x.ItemID, - newPlanTiered: (x) => x.ItemID, - newPlanBulk: (x) => x.ItemID, - bulkWithFilters: (x) => x.ItemID, - newPlanPackage: (x) => x.ItemID, - newPlanMatrix: (x) => x.ItemID, - newPlanThresholdTotalAmount: (x) => x.ItemID, - newPlanTieredPackage: (x) => x.ItemID, - newPlanTieredWithMinimum: (x) => x.ItemID, - newPlanGroupedTiered: (x) => x.ItemID, - newPlanTieredPackageWithMinimum: (x) => x.ItemID, - newPlanPackageWithAllocation: (x) => x.ItemID, - newPlanUnitWithPercent: (x) => x.ItemID, - newPlanMatrixWithAllocation: (x) => x.ItemID, - tieredWithProration: (x) => x.ItemID, - newPlanUnitWithProration: (x) => x.ItemID, - newPlanGroupedAllocation: (x) => x.ItemID, - newPlanBulkWithProration: (x) => x.ItemID, - newPlanGroupedWithProratedMinimum: (x) => x.ItemID, - newPlanGroupedWithMeteredMinimum: (x) => x.ItemID, - groupedWithMinMaxThresholds: (x) => x.ItemID, - newPlanMatrixWithDisplayName: (x) => x.ItemID, - newPlanGroupedTieredPackage: (x) => x.ItemID, - newPlanMaxGroupTieredPackage: (x) => x.ItemID, - newPlanScalableMatrixWithUnitPricing: (x) => x.ItemID, - newPlanScalableMatrixWithTieredPricing: (x) => x.ItemID, - newPlanCumulativeGroupedBulk: (x) => x.ItemID, - cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, - newPlanMinimumComposite: (x) => x.ItemID, - percent: (x) => x.ItemID, - eventOutput: (x) => x.ItemID - ); - } + this.Value = value; + this._element = element; } - public string Name + public ReplacePricePrice(JsonElement element) { - get - { - return Match( - newPlanUnit: (x) => x.Name, - newPlanTiered: (x) => x.Name, - newPlanBulk: (x) => x.Name, - bulkWithFilters: (x) => x.Name, - newPlanPackage: (x) => x.Name, - newPlanMatrix: (x) => x.Name, - newPlanThresholdTotalAmount: (x) => x.Name, - newPlanTieredPackage: (x) => x.Name, - newPlanTieredWithMinimum: (x) => x.Name, - newPlanGroupedTiered: (x) => x.Name, - newPlanTieredPackageWithMinimum: (x) => x.Name, - newPlanPackageWithAllocation: (x) => x.Name, - newPlanUnitWithPercent: (x) => x.Name, - newPlanMatrixWithAllocation: (x) => x.Name, - tieredWithProration: (x) => x.Name, - newPlanUnitWithProration: (x) => x.Name, - newPlanGroupedAllocation: (x) => x.Name, - newPlanBulkWithProration: (x) => x.Name, - newPlanGroupedWithProratedMinimum: (x) => x.Name, - newPlanGroupedWithMeteredMinimum: (x) => x.Name, - groupedWithMinMaxThresholds: (x) => x.Name, - newPlanMatrixWithDisplayName: (x) => x.Name, - newPlanGroupedTieredPackage: (x) => x.Name, - newPlanMaxGroupTieredPackage: (x) => x.Name, - newPlanScalableMatrixWithUnitPricing: (x) => x.Name, - newPlanScalableMatrixWithTieredPricing: (x) => x.Name, - newPlanCumulativeGroupedBulk: (x) => x.Name, - cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, - newPlanMinimumComposite: (x) => x.Name, - percent: (x) => x.Name, - eventOutput: (x) => x.Name - ); - } + this._element = element; } - public string? BillableMetricID + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanUnit(out var value)) { + /// // `value` is of type `NewPlanUnitPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanUnit([NotNullWhen(true)] out NewPlanUnitPrice? value) { - get - { - return Match( - newPlanUnit: (x) => x.BillableMetricID, - newPlanTiered: (x) => x.BillableMetricID, - newPlanBulk: (x) => x.BillableMetricID, - bulkWithFilters: (x) => x.BillableMetricID, - newPlanPackage: (x) => x.BillableMetricID, - newPlanMatrix: (x) => x.BillableMetricID, - newPlanThresholdTotalAmount: (x) => x.BillableMetricID, - newPlanTieredPackage: (x) => x.BillableMetricID, - newPlanTieredWithMinimum: (x) => x.BillableMetricID, - newPlanGroupedTiered: (x) => x.BillableMetricID, - newPlanTieredPackageWithMinimum: (x) => x.BillableMetricID, - newPlanPackageWithAllocation: (x) => x.BillableMetricID, - newPlanUnitWithPercent: (x) => x.BillableMetricID, - newPlanMatrixWithAllocation: (x) => x.BillableMetricID, - tieredWithProration: (x) => x.BillableMetricID, - newPlanUnitWithProration: (x) => x.BillableMetricID, - newPlanGroupedAllocation: (x) => x.BillableMetricID, - newPlanBulkWithProration: (x) => x.BillableMetricID, - newPlanGroupedWithProratedMinimum: (x) => x.BillableMetricID, - newPlanGroupedWithMeteredMinimum: (x) => x.BillableMetricID, - groupedWithMinMaxThresholds: (x) => x.BillableMetricID, - newPlanMatrixWithDisplayName: (x) => x.BillableMetricID, - newPlanGroupedTieredPackage: (x) => x.BillableMetricID, - newPlanMaxGroupTieredPackage: (x) => x.BillableMetricID, - newPlanScalableMatrixWithUnitPricing: (x) => x.BillableMetricID, - newPlanScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, - newPlanCumulativeGroupedBulk: (x) => x.BillableMetricID, - cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, - newPlanMinimumComposite: (x) => x.BillableMetricID, - percent: (x) => x.BillableMetricID, - eventOutput: (x) => x.BillableMetricID - ); - } + value = this.Value as NewPlanUnitPrice; + return value != null; } - public bool? BilledInAdvance + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanTiered(out var value)) { + /// // `value` is of type `NewPlanTieredPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanTiered([NotNullWhen(true)] out NewPlanTieredPrice? value) { - get - { - return Match( - newPlanUnit: (x) => x.BilledInAdvance, - newPlanTiered: (x) => x.BilledInAdvance, - newPlanBulk: (x) => x.BilledInAdvance, - bulkWithFilters: (x) => x.BilledInAdvance, - newPlanPackage: (x) => x.BilledInAdvance, - newPlanMatrix: (x) => x.BilledInAdvance, - newPlanThresholdTotalAmount: (x) => x.BilledInAdvance, - newPlanTieredPackage: (x) => x.BilledInAdvance, - newPlanTieredWithMinimum: (x) => x.BilledInAdvance, - newPlanGroupedTiered: (x) => x.BilledInAdvance, - newPlanTieredPackageWithMinimum: (x) => x.BilledInAdvance, - newPlanPackageWithAllocation: (x) => x.BilledInAdvance, - newPlanUnitWithPercent: (x) => x.BilledInAdvance, - newPlanMatrixWithAllocation: (x) => x.BilledInAdvance, - tieredWithProration: (x) => x.BilledInAdvance, - newPlanUnitWithProration: (x) => x.BilledInAdvance, - newPlanGroupedAllocation: (x) => x.BilledInAdvance, - newPlanBulkWithProration: (x) => x.BilledInAdvance, - newPlanGroupedWithProratedMinimum: (x) => x.BilledInAdvance, - newPlanGroupedWithMeteredMinimum: (x) => x.BilledInAdvance, - groupedWithMinMaxThresholds: (x) => x.BilledInAdvance, - newPlanMatrixWithDisplayName: (x) => x.BilledInAdvance, - newPlanGroupedTieredPackage: (x) => x.BilledInAdvance, - newPlanMaxGroupTieredPackage: (x) => x.BilledInAdvance, - newPlanScalableMatrixWithUnitPricing: (x) => x.BilledInAdvance, - newPlanScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, - newPlanCumulativeGroupedBulk: (x) => x.BilledInAdvance, - cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, - newPlanMinimumComposite: (x) => x.BilledInAdvance, - percent: (x) => x.BilledInAdvance, - eventOutput: (x) => x.BilledInAdvance - ); - } + value = this.Value as NewPlanTieredPrice; + return value != null; } - public NewBillingCycleConfiguration? BillingCycleConfiguration + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanBulk(out var value)) { + /// // `value` is of type `NewPlanBulkPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanBulk([NotNullWhen(true)] out NewPlanBulkPrice? value) { - get - { - return Match( - newPlanUnit: (x) => x.BillingCycleConfiguration, - newPlanTiered: (x) => x.BillingCycleConfiguration, - newPlanBulk: (x) => x.BillingCycleConfiguration, - bulkWithFilters: (x) => x.BillingCycleConfiguration, - newPlanPackage: (x) => x.BillingCycleConfiguration, - newPlanMatrix: (x) => x.BillingCycleConfiguration, - newPlanThresholdTotalAmount: (x) => x.BillingCycleConfiguration, - newPlanTieredPackage: (x) => x.BillingCycleConfiguration, - newPlanTieredWithMinimum: (x) => x.BillingCycleConfiguration, - newPlanGroupedTiered: (x) => x.BillingCycleConfiguration, - newPlanTieredPackageWithMinimum: (x) => x.BillingCycleConfiguration, - newPlanPackageWithAllocation: (x) => x.BillingCycleConfiguration, - newPlanUnitWithPercent: (x) => x.BillingCycleConfiguration, - newPlanMatrixWithAllocation: (x) => x.BillingCycleConfiguration, - tieredWithProration: (x) => x.BillingCycleConfiguration, - newPlanUnitWithProration: (x) => x.BillingCycleConfiguration, - newPlanGroupedAllocation: (x) => x.BillingCycleConfiguration, - newPlanBulkWithProration: (x) => x.BillingCycleConfiguration, - newPlanGroupedWithProratedMinimum: (x) => x.BillingCycleConfiguration, - newPlanGroupedWithMeteredMinimum: (x) => x.BillingCycleConfiguration, - groupedWithMinMaxThresholds: (x) => x.BillingCycleConfiguration, - newPlanMatrixWithDisplayName: (x) => x.BillingCycleConfiguration, - newPlanGroupedTieredPackage: (x) => x.BillingCycleConfiguration, - newPlanMaxGroupTieredPackage: (x) => x.BillingCycleConfiguration, - newPlanScalableMatrixWithUnitPricing: (x) => x.BillingCycleConfiguration, - newPlanScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, - newPlanCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, - cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, - newPlanMinimumComposite: (x) => x.BillingCycleConfiguration, - percent: (x) => x.BillingCycleConfiguration, - eventOutput: (x) => x.BillingCycleConfiguration - ); - } + value = this.Value as NewPlanBulkPrice; + return value != null; } - public double? ConversionRate + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBulkWithFilters(out var value)) { + /// // `value` is of type `ReplacePricePriceBulkWithFilters` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulkWithFilters( + [NotNullWhen(true)] out ReplacePricePriceBulkWithFilters? value + ) { - get - { - return Match( - newPlanUnit: (x) => x.ConversionRate, - newPlanTiered: (x) => x.ConversionRate, - newPlanBulk: (x) => x.ConversionRate, - bulkWithFilters: (x) => x.ConversionRate, - newPlanPackage: (x) => x.ConversionRate, - newPlanMatrix: (x) => x.ConversionRate, - newPlanThresholdTotalAmount: (x) => x.ConversionRate, - newPlanTieredPackage: (x) => x.ConversionRate, - newPlanTieredWithMinimum: (x) => x.ConversionRate, - newPlanGroupedTiered: (x) => x.ConversionRate, - newPlanTieredPackageWithMinimum: (x) => x.ConversionRate, - newPlanPackageWithAllocation: (x) => x.ConversionRate, - newPlanUnitWithPercent: (x) => x.ConversionRate, - newPlanMatrixWithAllocation: (x) => x.ConversionRate, - tieredWithProration: (x) => x.ConversionRate, - newPlanUnitWithProration: (x) => x.ConversionRate, - newPlanGroupedAllocation: (x) => x.ConversionRate, - newPlanBulkWithProration: (x) => x.ConversionRate, - newPlanGroupedWithProratedMinimum: (x) => x.ConversionRate, - newPlanGroupedWithMeteredMinimum: (x) => x.ConversionRate, - groupedWithMinMaxThresholds: (x) => x.ConversionRate, - newPlanMatrixWithDisplayName: (x) => x.ConversionRate, - newPlanGroupedTieredPackage: (x) => x.ConversionRate, - newPlanMaxGroupTieredPackage: (x) => x.ConversionRate, - newPlanScalableMatrixWithUnitPricing: (x) => x.ConversionRate, - newPlanScalableMatrixWithTieredPricing: (x) => x.ConversionRate, - newPlanCumulativeGroupedBulk: (x) => x.ConversionRate, - cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, - newPlanMinimumComposite: (x) => x.ConversionRate, - percent: (x) => x.ConversionRate, - eventOutput: (x) => x.ConversionRate - ); - } + value = this.Value as ReplacePricePriceBulkWithFilters; + return value != null; } - public string? Currency + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanPackage(out var value)) { + /// // `value` is of type `NewPlanPackagePrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanPackage([NotNullWhen(true)] out NewPlanPackagePrice? value) { - get - { - return Match( - newPlanUnit: (x) => x.Currency, - newPlanTiered: (x) => x.Currency, - newPlanBulk: (x) => x.Currency, - bulkWithFilters: (x) => x.Currency, - newPlanPackage: (x) => x.Currency, - newPlanMatrix: (x) => x.Currency, - newPlanThresholdTotalAmount: (x) => x.Currency, - newPlanTieredPackage: (x) => x.Currency, - newPlanTieredWithMinimum: (x) => x.Currency, - newPlanGroupedTiered: (x) => x.Currency, - newPlanTieredPackageWithMinimum: (x) => x.Currency, - newPlanPackageWithAllocation: (x) => x.Currency, - newPlanUnitWithPercent: (x) => x.Currency, - newPlanMatrixWithAllocation: (x) => x.Currency, - tieredWithProration: (x) => x.Currency, - newPlanUnitWithProration: (x) => x.Currency, - newPlanGroupedAllocation: (x) => x.Currency, - newPlanBulkWithProration: (x) => x.Currency, - newPlanGroupedWithProratedMinimum: (x) => x.Currency, - newPlanGroupedWithMeteredMinimum: (x) => x.Currency, - groupedWithMinMaxThresholds: (x) => x.Currency, - newPlanMatrixWithDisplayName: (x) => x.Currency, - newPlanGroupedTieredPackage: (x) => x.Currency, - newPlanMaxGroupTieredPackage: (x) => x.Currency, - newPlanScalableMatrixWithUnitPricing: (x) => x.Currency, - newPlanScalableMatrixWithTieredPricing: (x) => x.Currency, - newPlanCumulativeGroupedBulk: (x) => x.Currency, - cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, - newPlanMinimumComposite: (x) => x.Currency, - percent: (x) => x.Currency, - eventOutput: (x) => x.Currency - ); - } + value = this.Value as NewPlanPackagePrice; + return value != null; } - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanMatrix(out var value)) { + /// // `value` is of type `NewPlanMatrixPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanMatrix([NotNullWhen(true)] out NewPlanMatrixPrice? value) { - get - { - return Match( - newPlanUnit: (x) => x.DimensionalPriceConfiguration, - newPlanTiered: (x) => x.DimensionalPriceConfiguration, - newPlanBulk: (x) => x.DimensionalPriceConfiguration, - bulkWithFilters: (x) => x.DimensionalPriceConfiguration, - newPlanPackage: (x) => x.DimensionalPriceConfiguration, - newPlanMatrix: (x) => x.DimensionalPriceConfiguration, - newPlanThresholdTotalAmount: (x) => x.DimensionalPriceConfiguration, - newPlanTieredPackage: (x) => x.DimensionalPriceConfiguration, - newPlanTieredWithMinimum: (x) => x.DimensionalPriceConfiguration, - newPlanGroupedTiered: (x) => x.DimensionalPriceConfiguration, - newPlanTieredPackageWithMinimum: (x) => x.DimensionalPriceConfiguration, - newPlanPackageWithAllocation: (x) => x.DimensionalPriceConfiguration, - newPlanUnitWithPercent: (x) => x.DimensionalPriceConfiguration, - newPlanMatrixWithAllocation: (x) => x.DimensionalPriceConfiguration, - tieredWithProration: (x) => x.DimensionalPriceConfiguration, - newPlanUnitWithProration: (x) => x.DimensionalPriceConfiguration, - newPlanGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - newPlanBulkWithProration: (x) => x.DimensionalPriceConfiguration, - newPlanGroupedWithProratedMinimum: (x) => x.DimensionalPriceConfiguration, - newPlanGroupedWithMeteredMinimum: (x) => x.DimensionalPriceConfiguration, - groupedWithMinMaxThresholds: (x) => x.DimensionalPriceConfiguration, - newPlanMatrixWithDisplayName: (x) => x.DimensionalPriceConfiguration, - newPlanGroupedTieredPackage: (x) => x.DimensionalPriceConfiguration, - newPlanMaxGroupTieredPackage: (x) => x.DimensionalPriceConfiguration, - newPlanScalableMatrixWithUnitPricing: (x) => x.DimensionalPriceConfiguration, - newPlanScalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, - newPlanCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, - cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, - newPlanMinimumComposite: (x) => x.DimensionalPriceConfiguration, - percent: (x) => x.DimensionalPriceConfiguration, - eventOutput: (x) => x.DimensionalPriceConfiguration - ); - } + value = this.Value as NewPlanMatrixPrice; + return value != null; } - public string? ExternalPriceID + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanThresholdTotalAmount(out var value)) { + /// // `value` is of type `NewPlanThresholdTotalAmountPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanThresholdTotalAmount( + [NotNullWhen(true)] out NewPlanThresholdTotalAmountPrice? value + ) { - get - { - return Match( - newPlanUnit: (x) => x.ExternalPriceID, - newPlanTiered: (x) => x.ExternalPriceID, - newPlanBulk: (x) => x.ExternalPriceID, - bulkWithFilters: (x) => x.ExternalPriceID, - newPlanPackage: (x) => x.ExternalPriceID, - newPlanMatrix: (x) => x.ExternalPriceID, - newPlanThresholdTotalAmount: (x) => x.ExternalPriceID, - newPlanTieredPackage: (x) => x.ExternalPriceID, - newPlanTieredWithMinimum: (x) => x.ExternalPriceID, - newPlanGroupedTiered: (x) => x.ExternalPriceID, - newPlanTieredPackageWithMinimum: (x) => x.ExternalPriceID, - newPlanPackageWithAllocation: (x) => x.ExternalPriceID, - newPlanUnitWithPercent: (x) => x.ExternalPriceID, - newPlanMatrixWithAllocation: (x) => x.ExternalPriceID, - tieredWithProration: (x) => x.ExternalPriceID, - newPlanUnitWithProration: (x) => x.ExternalPriceID, - newPlanGroupedAllocation: (x) => x.ExternalPriceID, - newPlanBulkWithProration: (x) => x.ExternalPriceID, - newPlanGroupedWithProratedMinimum: (x) => x.ExternalPriceID, - newPlanGroupedWithMeteredMinimum: (x) => x.ExternalPriceID, - groupedWithMinMaxThresholds: (x) => x.ExternalPriceID, - newPlanMatrixWithDisplayName: (x) => x.ExternalPriceID, - newPlanGroupedTieredPackage: (x) => x.ExternalPriceID, - newPlanMaxGroupTieredPackage: (x) => x.ExternalPriceID, - newPlanScalableMatrixWithUnitPricing: (x) => x.ExternalPriceID, - newPlanScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, - newPlanCumulativeGroupedBulk: (x) => x.ExternalPriceID, - cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, - newPlanMinimumComposite: (x) => x.ExternalPriceID, - percent: (x) => x.ExternalPriceID, - eventOutput: (x) => x.ExternalPriceID - ); - } + value = this.Value as NewPlanThresholdTotalAmountPrice; + return value != null; } - public double? FixedPriceQuantity + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanTieredPackage(out var value)) { + /// // `value` is of type `NewPlanTieredPackagePrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanTieredPackage( + [NotNullWhen(true)] out NewPlanTieredPackagePrice? value + ) { - get - { - return Match( - newPlanUnit: (x) => x.FixedPriceQuantity, - newPlanTiered: (x) => x.FixedPriceQuantity, - newPlanBulk: (x) => x.FixedPriceQuantity, - bulkWithFilters: (x) => x.FixedPriceQuantity, - newPlanPackage: (x) => x.FixedPriceQuantity, - newPlanMatrix: (x) => x.FixedPriceQuantity, - newPlanThresholdTotalAmount: (x) => x.FixedPriceQuantity, - newPlanTieredPackage: (x) => x.FixedPriceQuantity, - newPlanTieredWithMinimum: (x) => x.FixedPriceQuantity, - newPlanGroupedTiered: (x) => x.FixedPriceQuantity, - newPlanTieredPackageWithMinimum: (x) => x.FixedPriceQuantity, - newPlanPackageWithAllocation: (x) => x.FixedPriceQuantity, - newPlanUnitWithPercent: (x) => x.FixedPriceQuantity, - newPlanMatrixWithAllocation: (x) => x.FixedPriceQuantity, - tieredWithProration: (x) => x.FixedPriceQuantity, - newPlanUnitWithProration: (x) => x.FixedPriceQuantity, - newPlanGroupedAllocation: (x) => x.FixedPriceQuantity, - newPlanBulkWithProration: (x) => x.FixedPriceQuantity, - newPlanGroupedWithProratedMinimum: (x) => x.FixedPriceQuantity, - newPlanGroupedWithMeteredMinimum: (x) => x.FixedPriceQuantity, - groupedWithMinMaxThresholds: (x) => x.FixedPriceQuantity, - newPlanMatrixWithDisplayName: (x) => x.FixedPriceQuantity, - newPlanGroupedTieredPackage: (x) => x.FixedPriceQuantity, - newPlanMaxGroupTieredPackage: (x) => x.FixedPriceQuantity, - newPlanScalableMatrixWithUnitPricing: (x) => x.FixedPriceQuantity, - newPlanScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, - newPlanCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, - cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, - newPlanMinimumComposite: (x) => x.FixedPriceQuantity, - percent: (x) => x.FixedPriceQuantity, - eventOutput: (x) => x.FixedPriceQuantity - ); - } + value = this.Value as NewPlanTieredPackagePrice; + return value != null; } - public string? InvoiceGroupingKey + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanTieredWithMinimum(out var value)) { + /// // `value` is of type `NewPlanTieredWithMinimumPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanTieredWithMinimum( + [NotNullWhen(true)] out NewPlanTieredWithMinimumPrice? value + ) { - get - { - return Match( - newPlanUnit: (x) => x.InvoiceGroupingKey, - newPlanTiered: (x) => x.InvoiceGroupingKey, - newPlanBulk: (x) => x.InvoiceGroupingKey, - bulkWithFilters: (x) => x.InvoiceGroupingKey, - newPlanPackage: (x) => x.InvoiceGroupingKey, - newPlanMatrix: (x) => x.InvoiceGroupingKey, - newPlanThresholdTotalAmount: (x) => x.InvoiceGroupingKey, - newPlanTieredPackage: (x) => x.InvoiceGroupingKey, - newPlanTieredWithMinimum: (x) => x.InvoiceGroupingKey, - newPlanGroupedTiered: (x) => x.InvoiceGroupingKey, - newPlanTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, - newPlanPackageWithAllocation: (x) => x.InvoiceGroupingKey, - newPlanUnitWithPercent: (x) => x.InvoiceGroupingKey, - newPlanMatrixWithAllocation: (x) => x.InvoiceGroupingKey, - tieredWithProration: (x) => x.InvoiceGroupingKey, - newPlanUnitWithProration: (x) => x.InvoiceGroupingKey, - newPlanGroupedAllocation: (x) => x.InvoiceGroupingKey, - newPlanBulkWithProration: (x) => x.InvoiceGroupingKey, - newPlanGroupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, - newPlanGroupedWithMeteredMinimum: (x) => x.InvoiceGroupingKey, - groupedWithMinMaxThresholds: (x) => x.InvoiceGroupingKey, - newPlanMatrixWithDisplayName: (x) => x.InvoiceGroupingKey, - newPlanGroupedTieredPackage: (x) => x.InvoiceGroupingKey, - newPlanMaxGroupTieredPackage: (x) => x.InvoiceGroupingKey, - newPlanScalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, - newPlanScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, - newPlanCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, - cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, - newPlanMinimumComposite: (x) => x.InvoiceGroupingKey, - percent: (x) => x.InvoiceGroupingKey, - eventOutput: (x) => x.InvoiceGroupingKey - ); - } + value = this.Value as NewPlanTieredWithMinimumPrice; + return value != null; } - public NewBillingCycleConfiguration? InvoicingCycleConfiguration - { - get - { - return Match( - newPlanUnit: (x) => x.InvoicingCycleConfiguration, - newPlanTiered: (x) => x.InvoicingCycleConfiguration, - newPlanBulk: (x) => x.InvoicingCycleConfiguration, - bulkWithFilters: (x) => x.InvoicingCycleConfiguration, - newPlanPackage: (x) => x.InvoicingCycleConfiguration, - newPlanMatrix: (x) => x.InvoicingCycleConfiguration, - newPlanThresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, - newPlanTieredPackage: (x) => x.InvoicingCycleConfiguration, - newPlanTieredWithMinimum: (x) => x.InvoicingCycleConfiguration, - newPlanGroupedTiered: (x) => x.InvoicingCycleConfiguration, - newPlanTieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, - newPlanPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, - newPlanUnitWithPercent: (x) => x.InvoicingCycleConfiguration, - newPlanMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, - tieredWithProration: (x) => x.InvoicingCycleConfiguration, - newPlanUnitWithProration: (x) => x.InvoicingCycleConfiguration, - newPlanGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - newPlanBulkWithProration: (x) => x.InvoicingCycleConfiguration, - newPlanGroupedWithProratedMinimum: (x) => x.InvoicingCycleConfiguration, - newPlanGroupedWithMeteredMinimum: (x) => x.InvoicingCycleConfiguration, - groupedWithMinMaxThresholds: (x) => x.InvoicingCycleConfiguration, - newPlanMatrixWithDisplayName: (x) => x.InvoicingCycleConfiguration, - newPlanGroupedTieredPackage: (x) => x.InvoicingCycleConfiguration, - newPlanMaxGroupTieredPackage: (x) => x.InvoicingCycleConfiguration, - newPlanScalableMatrixWithUnitPricing: (x) => x.InvoicingCycleConfiguration, - newPlanScalableMatrixWithTieredPricing: (x) => x.InvoicingCycleConfiguration, - newPlanCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, - cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, - newPlanMinimumComposite: (x) => x.InvoicingCycleConfiguration, - percent: (x) => x.InvoicingCycleConfiguration, - eventOutput: (x) => x.InvoicingCycleConfiguration - ); - } - } - - public string? ReferenceID - { - get - { - return Match( - newPlanUnit: (x) => x.ReferenceID, - newPlanTiered: (x) => x.ReferenceID, - newPlanBulk: (x) => x.ReferenceID, - bulkWithFilters: (x) => x.ReferenceID, - newPlanPackage: (x) => x.ReferenceID, - newPlanMatrix: (x) => x.ReferenceID, - newPlanThresholdTotalAmount: (x) => x.ReferenceID, - newPlanTieredPackage: (x) => x.ReferenceID, - newPlanTieredWithMinimum: (x) => x.ReferenceID, - newPlanGroupedTiered: (x) => x.ReferenceID, - newPlanTieredPackageWithMinimum: (x) => x.ReferenceID, - newPlanPackageWithAllocation: (x) => x.ReferenceID, - newPlanUnitWithPercent: (x) => x.ReferenceID, - newPlanMatrixWithAllocation: (x) => x.ReferenceID, - tieredWithProration: (x) => x.ReferenceID, - newPlanUnitWithProration: (x) => x.ReferenceID, - newPlanGroupedAllocation: (x) => x.ReferenceID, - newPlanBulkWithProration: (x) => x.ReferenceID, - newPlanGroupedWithProratedMinimum: (x) => x.ReferenceID, - newPlanGroupedWithMeteredMinimum: (x) => x.ReferenceID, - groupedWithMinMaxThresholds: (x) => x.ReferenceID, - newPlanMatrixWithDisplayName: (x) => x.ReferenceID, - newPlanGroupedTieredPackage: (x) => x.ReferenceID, - newPlanMaxGroupTieredPackage: (x) => x.ReferenceID, - newPlanScalableMatrixWithUnitPricing: (x) => x.ReferenceID, - newPlanScalableMatrixWithTieredPricing: (x) => x.ReferenceID, - newPlanCumulativeGroupedBulk: (x) => x.ReferenceID, - cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, - newPlanMinimumComposite: (x) => x.ReferenceID, - percent: (x) => x.ReferenceID, - eventOutput: (x) => x.ReferenceID - ); - } - } - - public ReplacePricePrice(NewPlanUnitPrice value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanGroupedTiered(out var value)) { + /// // `value` is of type `NewPlanGroupedTieredPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanGroupedTiered( + [NotNullWhen(true)] out NewPlanGroupedTieredPrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewPlanGroupedTieredPrice; + return value != null; } - public ReplacePricePrice(NewPlanTieredPrice value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanTieredPackageWithMinimum(out var value)) { + /// // `value` is of type `NewPlanTieredPackageWithMinimumPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanTieredPackageWithMinimum( + [NotNullWhen(true)] out NewPlanTieredPackageWithMinimumPrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewPlanTieredPackageWithMinimumPrice; + return value != null; } - public ReplacePricePrice(NewPlanBulkPrice value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanPackageWithAllocation(out var value)) { + /// // `value` is of type `NewPlanPackageWithAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanPackageWithAllocation( + [NotNullWhen(true)] out NewPlanPackageWithAllocationPrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewPlanPackageWithAllocationPrice; + return value != null; } - public ReplacePricePrice(ReplacePricePriceBulkWithFilters value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanUnitWithPercent(out var value)) { + /// // `value` is of type `NewPlanUnitWithPercentPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanUnitWithPercent( + [NotNullWhen(true)] out NewPlanUnitWithPercentPrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewPlanUnitWithPercentPrice; + return value != null; } - public ReplacePricePrice(NewPlanPackagePrice value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanMatrixWithAllocation(out var value)) { + /// // `value` is of type `NewPlanMatrixWithAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanMatrixWithAllocation( + [NotNullWhen(true)] out NewPlanMatrixWithAllocationPrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewPlanMatrixWithAllocationPrice; + return value != null; } - public ReplacePricePrice(NewPlanMatrixPrice value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTieredWithProration(out var value)) { + /// // `value` is of type `ReplacePricePriceTieredWithProration` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredWithProration( + [NotNullWhen(true)] out ReplacePricePriceTieredWithProration? value + ) { - this.Value = value; - this._element = element; + value = this.Value as ReplacePricePriceTieredWithProration; + return value != null; } - public ReplacePricePrice(NewPlanThresholdTotalAmountPrice value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanUnitWithProration(out var value)) { + /// // `value` is of type `NewPlanUnitWithProrationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanUnitWithProration( + [NotNullWhen(true)] out NewPlanUnitWithProrationPrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewPlanUnitWithProrationPrice; + return value != null; } - public ReplacePricePrice(NewPlanTieredPackagePrice value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanGroupedAllocation(out var value)) { + /// // `value` is of type `NewPlanGroupedAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanGroupedAllocation( + [NotNullWhen(true)] out NewPlanGroupedAllocationPrice? value + ) { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanTieredWithMinimumPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanGroupedTieredPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewPlanTieredPackageWithMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanPackageWithAllocationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanUnitWithPercentPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - ReplacePricePriceTieredWithProration value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanUnitWithProrationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanGroupedAllocationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanBulkWithProrationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewPlanGroupedWithProratedMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewPlanGroupedWithMeteredMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - ReplacePricePriceGroupedWithMinMaxThresholds value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanGroupedTieredPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewPlanScalableMatrixWithUnitPricingPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewPlanScalableMatrixWithTieredPricingPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - ReplacePricePriceCumulativeGroupedAllocation value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(ReplacePricePriceMinimum value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanMinimumCompositePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(ReplacePricePricePercent value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(ReplacePricePriceEventOutput value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(JsonElement element) - { - this._element = element; + value = this.Value as NewPlanGroupedAllocationPrice; + return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanUnit(out var value)) { - /// // `value` is of type `NewPlanUnitPrice` + /// if (instance.TryPickNewPlanBulkWithProration(out var value)) { + /// // `value` is of type `NewPlanBulkWithProrationPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanUnit([NotNullWhen(true)] out NewPlanUnitPrice? value) + public bool TryPickNewPlanBulkWithProration( + [NotNullWhen(true)] out NewPlanBulkWithProrationPrice? value + ) { - value = this.Value as NewPlanUnitPrice; + value = this.Value as NewPlanBulkWithProrationPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanTiered(out var value)) { - /// // `value` is of type `NewPlanTieredPrice` + /// if (instance.TryPickNewPlanGroupedWithProratedMinimum(out var value)) { + /// // `value` is of type `NewPlanGroupedWithProratedMinimumPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanTiered([NotNullWhen(true)] out NewPlanTieredPrice? value) + public bool TryPickNewPlanGroupedWithProratedMinimum( + [NotNullWhen(true)] out NewPlanGroupedWithProratedMinimumPrice? value + ) { - value = this.Value as NewPlanTieredPrice; + value = this.Value as NewPlanGroupedWithProratedMinimumPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanBulk(out var value)) { - /// // `value` is of type `NewPlanBulkPrice` + /// if (instance.TryPickNewPlanGroupedWithMeteredMinimum(out var value)) { + /// // `value` is of type `NewPlanGroupedWithMeteredMinimumPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanBulk([NotNullWhen(true)] out NewPlanBulkPrice? value) + public bool TryPickNewPlanGroupedWithMeteredMinimum( + [NotNullWhen(true)] out NewPlanGroupedWithMeteredMinimumPrice? value + ) { - value = this.Value as NewPlanBulkPrice; + value = this.Value as NewPlanGroupedWithMeteredMinimumPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickBulkWithFilters(out var value)) { - /// // `value` is of type `ReplacePricePriceBulkWithFilters` + /// if (instance.TryPickGroupedWithMinMaxThresholds(out var value)) { + /// // `value` is of type `ReplacePricePriceGroupedWithMinMaxThresholds` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickBulkWithFilters( - [NotNullWhen(true)] out ReplacePricePriceBulkWithFilters? value + public bool TryPickGroupedWithMinMaxThresholds( + [NotNullWhen(true)] out ReplacePricePriceGroupedWithMinMaxThresholds? value ) { - value = this.Value as ReplacePricePriceBulkWithFilters; + value = this.Value as ReplacePricePriceGroupedWithMinMaxThresholds; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanPackage(out var value)) { - /// // `value` is of type `NewPlanPackagePrice` + /// if (instance.TryPickNewPlanMatrixWithDisplayName(out var value)) { + /// // `value` is of type `NewPlanMatrixWithDisplayNamePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanPackage([NotNullWhen(true)] out NewPlanPackagePrice? value) + public bool TryPickNewPlanMatrixWithDisplayName( + [NotNullWhen(true)] out NewPlanMatrixWithDisplayNamePrice? value + ) { - value = this.Value as NewPlanPackagePrice; + value = this.Value as NewPlanMatrixWithDisplayNamePrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanMatrix(out var value)) { - /// // `value` is of type `NewPlanMatrixPrice` + /// if (instance.TryPickNewPlanGroupedTieredPackage(out var value)) { + /// // `value` is of type `NewPlanGroupedTieredPackagePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanMatrix([NotNullWhen(true)] out NewPlanMatrixPrice? value) + public bool TryPickNewPlanGroupedTieredPackage( + [NotNullWhen(true)] out NewPlanGroupedTieredPackagePrice? value + ) { - value = this.Value as NewPlanMatrixPrice; + value = this.Value as NewPlanGroupedTieredPackagePrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanThresholdTotalAmount(out var value)) { - /// // `value` is of type `NewPlanThresholdTotalAmountPrice` + /// if (instance.TryPickNewPlanMaxGroupTieredPackage(out var value)) { + /// // `value` is of type `NewPlanMaxGroupTieredPackagePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanThresholdTotalAmount( - [NotNullWhen(true)] out NewPlanThresholdTotalAmountPrice? value + public bool TryPickNewPlanMaxGroupTieredPackage( + [NotNullWhen(true)] out NewPlanMaxGroupTieredPackagePrice? value ) { - value = this.Value as NewPlanThresholdTotalAmountPrice; + value = this.Value as NewPlanMaxGroupTieredPackagePrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanTieredPackage(out var value)) { - /// // `value` is of type `NewPlanTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanTieredPackage( - [NotNullWhen(true)] out NewPlanTieredPackagePrice? value - ) - { - value = this.Value as NewPlanTieredPackagePrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanTieredWithMinimum(out var value)) { - /// // `value` is of type `NewPlanTieredWithMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanTieredWithMinimum( - [NotNullWhen(true)] out NewPlanTieredWithMinimumPrice? value - ) - { - value = this.Value as NewPlanTieredWithMinimumPrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanGroupedTiered(out var value)) { - /// // `value` is of type `NewPlanGroupedTieredPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanGroupedTiered( - [NotNullWhen(true)] out NewPlanGroupedTieredPrice? value - ) - { - value = this.Value as NewPlanGroupedTieredPrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanTieredPackageWithMinimum(out var value)) { - /// // `value` is of type `NewPlanTieredPackageWithMinimumPrice` + /// if (instance.TryPickNewPlanScalableMatrixWithUnitPricing(out var value)) { + /// // `value` is of type `NewPlanScalableMatrixWithUnitPricingPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanTieredPackageWithMinimum( - [NotNullWhen(true)] out NewPlanTieredPackageWithMinimumPrice? value + public bool TryPickNewPlanScalableMatrixWithUnitPricing( + [NotNullWhen(true)] out NewPlanScalableMatrixWithUnitPricingPrice? value ) { - value = this.Value as NewPlanTieredPackageWithMinimumPrice; + value = this.Value as NewPlanScalableMatrixWithUnitPricingPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanPackageWithAllocation(out var value)) { - /// // `value` is of type `NewPlanPackageWithAllocationPrice` + /// if (instance.TryPickNewPlanScalableMatrixWithTieredPricing(out var value)) { + /// // `value` is of type `NewPlanScalableMatrixWithTieredPricingPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanPackageWithAllocation( - [NotNullWhen(true)] out NewPlanPackageWithAllocationPrice? value + public bool TryPickNewPlanScalableMatrixWithTieredPricing( + [NotNullWhen(true)] out NewPlanScalableMatrixWithTieredPricingPrice? value ) { - value = this.Value as NewPlanPackageWithAllocationPrice; + value = this.Value as NewPlanScalableMatrixWithTieredPricingPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanUnitWithPercent(out var value)) { - /// // `value` is of type `NewPlanUnitWithPercentPrice` + /// if (instance.TryPickNewPlanCumulativeGroupedBulk(out var value)) { + /// // `value` is of type `NewPlanCumulativeGroupedBulkPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanUnitWithPercent( - [NotNullWhen(true)] out NewPlanUnitWithPercentPrice? value + public bool TryPickNewPlanCumulativeGroupedBulk( + [NotNullWhen(true)] out NewPlanCumulativeGroupedBulkPrice? value ) { - value = this.Value as NewPlanUnitWithPercentPrice; + value = this.Value as NewPlanCumulativeGroupedBulkPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanMatrixWithAllocation(out var value)) { - /// // `value` is of type `NewPlanMatrixWithAllocationPrice` + /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { + /// // `value` is of type `ReplacePricePriceCumulativeGroupedAllocation` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanMatrixWithAllocation( - [NotNullWhen(true)] out NewPlanMatrixWithAllocationPrice? value + public bool TryPickCumulativeGroupedAllocation( + [NotNullWhen(true)] out ReplacePricePriceCumulativeGroupedAllocation? value ) { - value = this.Value as NewPlanMatrixWithAllocationPrice; + value = this.Value as ReplacePricePriceCumulativeGroupedAllocation; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickTieredWithProration(out var value)) { - /// // `value` is of type `ReplacePricePriceTieredWithProration` + /// if (instance.TryPickNewPlanMinimumComposite(out var value)) { + /// // `value` is of type `NewPlanMinimumCompositePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTieredWithProration( - [NotNullWhen(true)] out ReplacePricePriceTieredWithProration? value + public bool TryPickNewPlanMinimumComposite( + [NotNullWhen(true)] out NewPlanMinimumCompositePrice? value ) { - value = this.Value as ReplacePricePriceTieredWithProration; + value = this.Value as NewPlanMinimumCompositePrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanUnitWithProration(out var value)) { - /// // `value` is of type `NewPlanUnitWithProrationPrice` + /// if (instance.TryPickPercent(out var value)) { + /// // `value` is of type `ReplacePricePricePercent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanUnitWithProration( - [NotNullWhen(true)] out NewPlanUnitWithProrationPrice? value - ) + public bool TryPickPercent([NotNullWhen(true)] out ReplacePricePricePercent? value) { - value = this.Value as NewPlanUnitWithProrationPrice; + value = this.Value as ReplacePricePricePercent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanGroupedAllocation(out var value)) { - /// // `value` is of type `NewPlanGroupedAllocationPrice` + /// if (instance.TryPickEventOutput(out var value)) { + /// // `value` is of type `ReplacePricePriceEventOutput` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanGroupedAllocation( - [NotNullWhen(true)] out NewPlanGroupedAllocationPrice? value - ) + public bool TryPickEventOutput([NotNullWhen(true)] out ReplacePricePriceEventOutput? value) { - value = this.Value as NewPlanGroupedAllocationPrice; + value = this.Value as ReplacePricePriceEventOutput; return value != null; } /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. + /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// - /// - /// if (instance.TryPickNewPlanBulkWithProration(out var value)) { - /// // `value` is of type `NewPlanBulkWithProrationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanBulkWithProration( - [NotNullWhen(true)] out NewPlanBulkWithProrationPrice? value - ) - { - value = this.Value as NewPlanBulkWithProrationPrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. /// - /// Consider using or if you need to handle every variant. + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// /// /// /// - /// if (instance.TryPickNewPlanGroupedWithProratedMinimum(out var value)) { - /// // `value` is of type `NewPlanGroupedWithProratedMinimumPrice` - /// Console.WriteLine(value); - /// } + /// instance.Switch( + /// (NewPlanUnitPrice value) => {...}, + /// (NewPlanTieredPrice value) => {...}, + /// (NewPlanBulkPrice value) => {...}, + /// (ReplacePricePriceBulkWithFilters value) => {...}, + /// (NewPlanPackagePrice value) => {...}, + /// (NewPlanMatrixPrice value) => {...}, + /// (NewPlanThresholdTotalAmountPrice value) => {...}, + /// (NewPlanTieredPackagePrice value) => {...}, + /// (NewPlanTieredWithMinimumPrice value) => {...}, + /// (NewPlanGroupedTieredPrice value) => {...}, + /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, + /// (NewPlanPackageWithAllocationPrice value) => {...}, + /// (NewPlanUnitWithPercentPrice value) => {...}, + /// (NewPlanMatrixWithAllocationPrice value) => {...}, + /// (ReplacePricePriceTieredWithProration value) => {...}, + /// (NewPlanUnitWithProrationPrice value) => {...}, + /// (NewPlanGroupedAllocationPrice value) => {...}, + /// (NewPlanBulkWithProrationPrice value) => {...}, + /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, + /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, + /// (ReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, + /// (NewPlanGroupedTieredPackagePrice value) => {...}, + /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, + /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, + /// (ReplacePricePriceCumulativeGroupedAllocation value) => {...}, + /// (NewPlanMinimumCompositePrice value) => {...}, + /// (ReplacePricePricePercent value) => {...}, + /// (ReplacePricePriceEventOutput value) => {...} + /// ); /// /// /// - public bool TryPickNewPlanGroupedWithProratedMinimum( - [NotNullWhen(true)] out NewPlanGroupedWithProratedMinimumPrice? value + public void Switch( + System::Action newPlanUnit, + System::Action newPlanTiered, + System::Action newPlanBulk, + System::Action bulkWithFilters, + System::Action newPlanPackage, + System::Action newPlanMatrix, + System::Action newPlanThresholdTotalAmount, + System::Action newPlanTieredPackage, + System::Action newPlanTieredWithMinimum, + System::Action newPlanGroupedTiered, + System::Action newPlanTieredPackageWithMinimum, + System::Action newPlanPackageWithAllocation, + System::Action newPlanUnitWithPercent, + System::Action newPlanMatrixWithAllocation, + System::Action tieredWithProration, + System::Action newPlanUnitWithProration, + System::Action newPlanGroupedAllocation, + System::Action newPlanBulkWithProration, + System::Action newPlanGroupedWithProratedMinimum, + System::Action newPlanGroupedWithMeteredMinimum, + System::Action groupedWithMinMaxThresholds, + System::Action newPlanMatrixWithDisplayName, + System::Action newPlanGroupedTieredPackage, + System::Action newPlanMaxGroupTieredPackage, + System::Action newPlanScalableMatrixWithUnitPricing, + System::Action newPlanScalableMatrixWithTieredPricing, + System::Action newPlanCumulativeGroupedBulk, + System::Action cumulativeGroupedAllocation, + System::Action newPlanMinimumComposite, + System::Action percent, + System::Action eventOutput ) { - value = this.Value as NewPlanGroupedWithProratedMinimumPrice; - return value != null; + switch (this.Value) + { + case NewPlanUnitPrice value: + newPlanUnit(value); + break; + case NewPlanTieredPrice value: + newPlanTiered(value); + break; + case NewPlanBulkPrice value: + newPlanBulk(value); + break; + case ReplacePricePriceBulkWithFilters value: + bulkWithFilters(value); + break; + case NewPlanPackagePrice value: + newPlanPackage(value); + break; + case NewPlanMatrixPrice value: + newPlanMatrix(value); + break; + case NewPlanThresholdTotalAmountPrice value: + newPlanThresholdTotalAmount(value); + break; + case NewPlanTieredPackagePrice value: + newPlanTieredPackage(value); + break; + case NewPlanTieredWithMinimumPrice value: + newPlanTieredWithMinimum(value); + break; + case NewPlanGroupedTieredPrice value: + newPlanGroupedTiered(value); + break; + case NewPlanTieredPackageWithMinimumPrice value: + newPlanTieredPackageWithMinimum(value); + break; + case NewPlanPackageWithAllocationPrice value: + newPlanPackageWithAllocation(value); + break; + case NewPlanUnitWithPercentPrice value: + newPlanUnitWithPercent(value); + break; + case NewPlanMatrixWithAllocationPrice value: + newPlanMatrixWithAllocation(value); + break; + case ReplacePricePriceTieredWithProration value: + tieredWithProration(value); + break; + case NewPlanUnitWithProrationPrice value: + newPlanUnitWithProration(value); + break; + case NewPlanGroupedAllocationPrice value: + newPlanGroupedAllocation(value); + break; + case NewPlanBulkWithProrationPrice value: + newPlanBulkWithProration(value); + break; + case NewPlanGroupedWithProratedMinimumPrice value: + newPlanGroupedWithProratedMinimum(value); + break; + case NewPlanGroupedWithMeteredMinimumPrice value: + newPlanGroupedWithMeteredMinimum(value); + break; + case ReplacePricePriceGroupedWithMinMaxThresholds value: + groupedWithMinMaxThresholds(value); + break; + case NewPlanMatrixWithDisplayNamePrice value: + newPlanMatrixWithDisplayName(value); + break; + case NewPlanGroupedTieredPackagePrice value: + newPlanGroupedTieredPackage(value); + break; + case NewPlanMaxGroupTieredPackagePrice value: + newPlanMaxGroupTieredPackage(value); + break; + case NewPlanScalableMatrixWithUnitPricingPrice value: + newPlanScalableMatrixWithUnitPricing(value); + break; + case NewPlanScalableMatrixWithTieredPricingPrice value: + newPlanScalableMatrixWithTieredPricing(value); + break; + case NewPlanCumulativeGroupedBulkPrice value: + newPlanCumulativeGroupedBulk(value); + break; + case ReplacePricePriceCumulativeGroupedAllocation value: + cumulativeGroupedAllocation(value); + break; + case NewPlanMinimumCompositePrice value: + newPlanMinimumComposite(value); + break; + case ReplacePricePricePercent value: + percent(value); + break; + case ReplacePricePriceEventOutput value: + eventOutput(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePrice" + ); + } } /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. /// - /// Consider using or if you need to handle every variant. + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// /// /// /// - /// if (instance.TryPickNewPlanGroupedWithMeteredMinimum(out var value)) { - /// // `value` is of type `NewPlanGroupedWithMeteredMinimumPrice` - /// Console.WriteLine(value); - /// } + /// var result = instance.Match( + /// (NewPlanUnitPrice value) => {...}, + /// (NewPlanTieredPrice value) => {...}, + /// (NewPlanBulkPrice value) => {...}, + /// (ReplacePricePriceBulkWithFilters value) => {...}, + /// (NewPlanPackagePrice value) => {...}, + /// (NewPlanMatrixPrice value) => {...}, + /// (NewPlanThresholdTotalAmountPrice value) => {...}, + /// (NewPlanTieredPackagePrice value) => {...}, + /// (NewPlanTieredWithMinimumPrice value) => {...}, + /// (NewPlanGroupedTieredPrice value) => {...}, + /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, + /// (NewPlanPackageWithAllocationPrice value) => {...}, + /// (NewPlanUnitWithPercentPrice value) => {...}, + /// (NewPlanMatrixWithAllocationPrice value) => {...}, + /// (ReplacePricePriceTieredWithProration value) => {...}, + /// (NewPlanUnitWithProrationPrice value) => {...}, + /// (NewPlanGroupedAllocationPrice value) => {...}, + /// (NewPlanBulkWithProrationPrice value) => {...}, + /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, + /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, + /// (ReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, + /// (NewPlanGroupedTieredPackagePrice value) => {...}, + /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, + /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, + /// (ReplacePricePriceCumulativeGroupedAllocation value) => {...}, + /// (NewPlanMinimumCompositePrice value) => {...}, + /// (ReplacePricePricePercent value) => {...}, + /// (ReplacePricePriceEventOutput value) => {...} + /// ); /// /// /// - public bool TryPickNewPlanGroupedWithMeteredMinimum( - [NotNullWhen(true)] out NewPlanGroupedWithMeteredMinimumPrice? value + public T Match( + System::Func newPlanUnit, + System::Func newPlanTiered, + System::Func newPlanBulk, + System::Func bulkWithFilters, + System::Func newPlanPackage, + System::Func newPlanMatrix, + System::Func newPlanThresholdTotalAmount, + System::Func newPlanTieredPackage, + System::Func newPlanTieredWithMinimum, + System::Func newPlanGroupedTiered, + System::Func newPlanTieredPackageWithMinimum, + System::Func newPlanPackageWithAllocation, + System::Func newPlanUnitWithPercent, + System::Func newPlanMatrixWithAllocation, + System::Func tieredWithProration, + System::Func newPlanUnitWithProration, + System::Func newPlanGroupedAllocation, + System::Func newPlanBulkWithProration, + System::Func newPlanGroupedWithProratedMinimum, + System::Func newPlanGroupedWithMeteredMinimum, + System::Func groupedWithMinMaxThresholds, + System::Func newPlanMatrixWithDisplayName, + System::Func newPlanGroupedTieredPackage, + System::Func newPlanMaxGroupTieredPackage, + System::Func< + NewPlanScalableMatrixWithUnitPricingPrice, + T + > newPlanScalableMatrixWithUnitPricing, + System::Func< + NewPlanScalableMatrixWithTieredPricingPrice, + T + > newPlanScalableMatrixWithTieredPricing, + System::Func newPlanCumulativeGroupedBulk, + System::Func cumulativeGroupedAllocation, + System::Func newPlanMinimumComposite, + System::Func percent, + System::Func eventOutput ) { - value = this.Value as NewPlanGroupedWithMeteredMinimumPrice; - return value != null; + return this.Value switch + { + NewPlanUnitPrice value => newPlanUnit(value), + NewPlanTieredPrice value => newPlanTiered(value), + NewPlanBulkPrice value => newPlanBulk(value), + ReplacePricePriceBulkWithFilters value => bulkWithFilters(value), + NewPlanPackagePrice value => newPlanPackage(value), + NewPlanMatrixPrice value => newPlanMatrix(value), + NewPlanThresholdTotalAmountPrice value => newPlanThresholdTotalAmount(value), + NewPlanTieredPackagePrice value => newPlanTieredPackage(value), + NewPlanTieredWithMinimumPrice value => newPlanTieredWithMinimum(value), + NewPlanGroupedTieredPrice value => newPlanGroupedTiered(value), + NewPlanTieredPackageWithMinimumPrice value => newPlanTieredPackageWithMinimum(value), + NewPlanPackageWithAllocationPrice value => newPlanPackageWithAllocation(value), + NewPlanUnitWithPercentPrice value => newPlanUnitWithPercent(value), + NewPlanMatrixWithAllocationPrice value => newPlanMatrixWithAllocation(value), + ReplacePricePriceTieredWithProration value => tieredWithProration(value), + NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), + NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), + NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), + NewPlanGroupedWithProratedMinimumPrice value => newPlanGroupedWithProratedMinimum( + value + ), + NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), + ReplacePricePriceGroupedWithMinMaxThresholds value => groupedWithMinMaxThresholds( + value + ), + NewPlanMatrixWithDisplayNamePrice value => newPlanMatrixWithDisplayName(value), + NewPlanGroupedTieredPackagePrice value => newPlanGroupedTieredPackage(value), + NewPlanMaxGroupTieredPackagePrice value => newPlanMaxGroupTieredPackage(value), + NewPlanScalableMatrixWithUnitPricingPrice value => newPlanScalableMatrixWithUnitPricing( + value + ), + NewPlanScalableMatrixWithTieredPricingPrice value => + newPlanScalableMatrixWithTieredPricing(value), + NewPlanCumulativeGroupedBulkPrice value => newPlanCumulativeGroupedBulk(value), + ReplacePricePriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation( + value + ), + NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), + ReplacePricePricePercent value => percent(value), + ReplacePricePriceEventOutput value => eventOutput(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePrice" + ), + }; } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickGroupedWithMinMaxThresholds(out var value)) { - /// // `value` is of type `ReplacePricePriceGroupedWithMinMaxThresholds` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] out ReplacePricePriceGroupedWithMinMaxThresholds? value - ) - { - value = this.Value as ReplacePricePriceGroupedWithMinMaxThresholds; - return value != null; - } + public static implicit operator ReplacePricePrice(NewPlanUnitPrice value) => new(value); - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanMatrixWithDisplayName(out var value)) { - /// // `value` is of type `NewPlanMatrixWithDisplayNamePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMatrixWithDisplayName( - [NotNullWhen(true)] out NewPlanMatrixWithDisplayNamePrice? value - ) - { - value = this.Value as NewPlanMatrixWithDisplayNamePrice; - return value != null; - } + public static implicit operator ReplacePricePrice(NewPlanTieredPrice value) => new(value); + + public static implicit operator ReplacePricePrice(NewPlanBulkPrice value) => new(value); + + public static implicit operator ReplacePricePrice(ReplacePricePriceBulkWithFilters value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanPackagePrice value) => new(value); + + public static implicit operator ReplacePricePrice(NewPlanMatrixPrice value) => new(value); + + public static implicit operator ReplacePricePrice(NewPlanThresholdTotalAmountPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanTieredPackagePrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanTieredWithMinimumPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanGroupedTieredPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanTieredPackageWithMinimumPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanPackageWithAllocationPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanUnitWithPercentPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanMatrixWithAllocationPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(ReplacePricePriceTieredWithProration value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanUnitWithProrationPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanGroupedAllocationPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanBulkWithProrationPrice value) => + new(value); + + public static implicit operator ReplacePricePrice( + NewPlanGroupedWithProratedMinimumPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + NewPlanGroupedWithMeteredMinimumPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + ReplacePricePriceGroupedWithMinMaxThresholds value + ) => new(value); + + public static implicit operator ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanGroupedTieredPackagePrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value) => + new(value); + + public static implicit operator ReplacePricePrice( + NewPlanScalableMatrixWithUnitPricingPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + NewPlanScalableMatrixWithTieredPricingPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice(NewPlanCumulativeGroupedBulkPrice value) => + new(value); + + public static implicit operator ReplacePricePrice( + ReplacePricePriceCumulativeGroupedAllocation value + ) => new(value); + + public static implicit operator ReplacePricePrice(NewPlanMinimumCompositePrice value) => + new(value); + + public static implicit operator ReplacePricePrice(ReplacePricePricePercent value) => new(value); + + public static implicit operator ReplacePricePrice(ReplacePricePriceEventOutput value) => + new(value); /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). /// - /// Consider using or if you need to handle every variant. + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). /// - /// - /// - /// if (instance.TryPickNewPlanGroupedTieredPackage(out var value)) { - /// // `value` is of type `NewPlanGroupedTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// + /// Thrown when the instance does not pass validation. + /// /// - public bool TryPickNewPlanGroupedTieredPackage( - [NotNullWhen(true)] out NewPlanGroupedTieredPackagePrice? value - ) + public override void Validate() { - value = this.Value as NewPlanGroupedTieredPackagePrice; - return value != null; + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePrice" + ); + } + this.Switch( + (newPlanUnit) => newPlanUnit.Validate(), + (newPlanTiered) => newPlanTiered.Validate(), + (newPlanBulk) => newPlanBulk.Validate(), + (bulkWithFilters) => bulkWithFilters.Validate(), + (newPlanPackage) => newPlanPackage.Validate(), + (newPlanMatrix) => newPlanMatrix.Validate(), + (newPlanThresholdTotalAmount) => newPlanThresholdTotalAmount.Validate(), + (newPlanTieredPackage) => newPlanTieredPackage.Validate(), + (newPlanTieredWithMinimum) => newPlanTieredWithMinimum.Validate(), + (newPlanGroupedTiered) => newPlanGroupedTiered.Validate(), + (newPlanTieredPackageWithMinimum) => newPlanTieredPackageWithMinimum.Validate(), + (newPlanPackageWithAllocation) => newPlanPackageWithAllocation.Validate(), + (newPlanUnitWithPercent) => newPlanUnitWithPercent.Validate(), + (newPlanMatrixWithAllocation) => newPlanMatrixWithAllocation.Validate(), + (tieredWithProration) => tieredWithProration.Validate(), + (newPlanUnitWithProration) => newPlanUnitWithProration.Validate(), + (newPlanGroupedAllocation) => newPlanGroupedAllocation.Validate(), + (newPlanBulkWithProration) => newPlanBulkWithProration.Validate(), + (newPlanGroupedWithProratedMinimum) => newPlanGroupedWithProratedMinimum.Validate(), + (newPlanGroupedWithMeteredMinimum) => newPlanGroupedWithMeteredMinimum.Validate(), + (groupedWithMinMaxThresholds) => groupedWithMinMaxThresholds.Validate(), + (newPlanMatrixWithDisplayName) => newPlanMatrixWithDisplayName.Validate(), + (newPlanGroupedTieredPackage) => newPlanGroupedTieredPackage.Validate(), + (newPlanMaxGroupTieredPackage) => newPlanMaxGroupTieredPackage.Validate(), + (newPlanScalableMatrixWithUnitPricing) => + newPlanScalableMatrixWithUnitPricing.Validate(), + (newPlanScalableMatrixWithTieredPricing) => + newPlanScalableMatrixWithTieredPricing.Validate(), + (newPlanCumulativeGroupedBulk) => newPlanCumulativeGroupedBulk.Validate(), + (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), + (newPlanMinimumComposite) => newPlanMinimumComposite.Validate(), + (percent) => percent.Validate(), + (eventOutput) => eventOutput.Validate() + ); } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanMaxGroupTieredPackage(out var value)) { - /// // `value` is of type `NewPlanMaxGroupTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMaxGroupTieredPackage( - [NotNullWhen(true)] out NewPlanMaxGroupTieredPackagePrice? value - ) + public virtual bool Equals(ReplacePricePrice? other) { - value = this.Value as NewPlanMaxGroupTieredPackagePrice; - return value != null; + return other != null && JsonElement.DeepEquals(this.Json, other.Json); } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanScalableMatrixWithUnitPricing(out var value)) { - /// // `value` is of type `NewPlanScalableMatrixWithUnitPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanScalableMatrixWithUnitPricing( - [NotNullWhen(true)] out NewPlanScalableMatrixWithUnitPricingPrice? value - ) + public override int GetHashCode() { - value = this.Value as NewPlanScalableMatrixWithUnitPricingPrice; - return value != null; + return 0; } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanScalableMatrixWithTieredPricing(out var value)) { - /// // `value` is of type `NewPlanScalableMatrixWithTieredPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanScalableMatrixWithTieredPricing( - [NotNullWhen(true)] out NewPlanScalableMatrixWithTieredPricingPrice? value + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class ReplacePricePriceConverter : JsonConverter +{ + public override ReplacePricePrice? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - value = this.Value as NewPlanScalableMatrixWithTieredPricingPrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanCumulativeGroupedBulk(out var value)) { - /// // `value` is of type `NewPlanCumulativeGroupedBulkPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanCumulativeGroupedBulk( - [NotNullWhen(true)] out NewPlanCumulativeGroupedBulkPrice? value - ) - { - value = this.Value as NewPlanCumulativeGroupedBulkPrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `ReplacePricePriceCumulativeGroupedAllocation` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] out ReplacePricePriceCumulativeGroupedAllocation? value - ) - { - value = this.Value as ReplacePricePriceCumulativeGroupedAllocation; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `ReplacePricePriceMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum([NotNullWhen(true)] out ReplacePricePriceMinimum? value) - { - value = this.Value as ReplacePricePriceMinimum; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanMinimumComposite(out var value)) { - /// // `value` is of type `NewPlanMinimumCompositePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMinimumComposite( - [NotNullWhen(true)] out NewPlanMinimumCompositePrice? value - ) - { - value = this.Value as NewPlanMinimumCompositePrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickPercent(out var value)) { - /// // `value` is of type `ReplacePricePricePercent` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickPercent([NotNullWhen(true)] out ReplacePricePricePercent? value) - { - value = this.Value as ReplacePricePricePercent; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickEventOutput(out var value)) { - /// // `value` is of type `ReplacePricePriceEventOutput` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickEventOutput([NotNullWhen(true)] out ReplacePricePriceEventOutput? value) - { - value = this.Value as ReplacePricePriceEventOutput; - return value != null; - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (NewPlanUnitPrice value) => {...}, - /// (NewPlanTieredPrice value) => {...}, - /// (NewPlanBulkPrice value) => {...}, - /// (ReplacePricePriceBulkWithFilters value) => {...}, - /// (NewPlanPackagePrice value) => {...}, - /// (NewPlanMatrixPrice value) => {...}, - /// (NewPlanThresholdTotalAmountPrice value) => {...}, - /// (NewPlanTieredPackagePrice value) => {...}, - /// (NewPlanTieredWithMinimumPrice value) => {...}, - /// (NewPlanGroupedTieredPrice value) => {...}, - /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, - /// (NewPlanPackageWithAllocationPrice value) => {...}, - /// (NewPlanUnitWithPercentPrice value) => {...}, - /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (ReplacePricePriceTieredWithProration value) => {...}, - /// (NewPlanUnitWithProrationPrice value) => {...}, - /// (NewPlanGroupedAllocationPrice value) => {...}, - /// (NewPlanBulkWithProrationPrice value) => {...}, - /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, - /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (ReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, - /// (NewPlanGroupedTieredPackagePrice value) => {...}, - /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, - /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, - /// (ReplacePricePriceCumulativeGroupedAllocation value) => {...}, - /// (ReplacePricePriceMinimum value) => {...}, - /// (NewPlanMinimumCompositePrice value) => {...}, - /// (ReplacePricePricePercent value) => {...}, - /// (ReplacePricePriceEventOutput value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action newPlanUnit, - System::Action newPlanTiered, - System::Action newPlanBulk, - System::Action bulkWithFilters, - System::Action newPlanPackage, - System::Action newPlanMatrix, - System::Action newPlanThresholdTotalAmount, - System::Action newPlanTieredPackage, - System::Action newPlanTieredWithMinimum, - System::Action newPlanGroupedTiered, - System::Action newPlanTieredPackageWithMinimum, - System::Action newPlanPackageWithAllocation, - System::Action newPlanUnitWithPercent, - System::Action newPlanMatrixWithAllocation, - System::Action tieredWithProration, - System::Action newPlanUnitWithProration, - System::Action newPlanGroupedAllocation, - System::Action newPlanBulkWithProration, - System::Action newPlanGroupedWithProratedMinimum, - System::Action newPlanGroupedWithMeteredMinimum, - System::Action groupedWithMinMaxThresholds, - System::Action newPlanMatrixWithDisplayName, - System::Action newPlanGroupedTieredPackage, - System::Action newPlanMaxGroupTieredPackage, - System::Action newPlanScalableMatrixWithUnitPricing, - System::Action newPlanScalableMatrixWithTieredPricing, - System::Action newPlanCumulativeGroupedBulk, - System::Action cumulativeGroupedAllocation, - System::Action minimum, - System::Action newPlanMinimumComposite, - System::Action percent, - System::Action eventOutput - ) - { - switch (this.Value) - { - case NewPlanUnitPrice value: - newPlanUnit(value); - break; - case NewPlanTieredPrice value: - newPlanTiered(value); - break; - case NewPlanBulkPrice value: - newPlanBulk(value); - break; - case ReplacePricePriceBulkWithFilters value: - bulkWithFilters(value); - break; - case NewPlanPackagePrice value: - newPlanPackage(value); - break; - case NewPlanMatrixPrice value: - newPlanMatrix(value); - break; - case NewPlanThresholdTotalAmountPrice value: - newPlanThresholdTotalAmount(value); - break; - case NewPlanTieredPackagePrice value: - newPlanTieredPackage(value); - break; - case NewPlanTieredWithMinimumPrice value: - newPlanTieredWithMinimum(value); - break; - case NewPlanGroupedTieredPrice value: - newPlanGroupedTiered(value); - break; - case NewPlanTieredPackageWithMinimumPrice value: - newPlanTieredPackageWithMinimum(value); - break; - case NewPlanPackageWithAllocationPrice value: - newPlanPackageWithAllocation(value); - break; - case NewPlanUnitWithPercentPrice value: - newPlanUnitWithPercent(value); - break; - case NewPlanMatrixWithAllocationPrice value: - newPlanMatrixWithAllocation(value); - break; - case ReplacePricePriceTieredWithProration value: - tieredWithProration(value); - break; - case NewPlanUnitWithProrationPrice value: - newPlanUnitWithProration(value); - break; - case NewPlanGroupedAllocationPrice value: - newPlanGroupedAllocation(value); - break; - case NewPlanBulkWithProrationPrice value: - newPlanBulkWithProration(value); - break; - case NewPlanGroupedWithProratedMinimumPrice value: - newPlanGroupedWithProratedMinimum(value); - break; - case NewPlanGroupedWithMeteredMinimumPrice value: - newPlanGroupedWithMeteredMinimum(value); - break; - case ReplacePricePriceGroupedWithMinMaxThresholds value: - groupedWithMinMaxThresholds(value); - break; - case NewPlanMatrixWithDisplayNamePrice value: - newPlanMatrixWithDisplayName(value); - break; - case NewPlanGroupedTieredPackagePrice value: - newPlanGroupedTieredPackage(value); - break; - case NewPlanMaxGroupTieredPackagePrice value: - newPlanMaxGroupTieredPackage(value); - break; - case NewPlanScalableMatrixWithUnitPricingPrice value: - newPlanScalableMatrixWithUnitPricing(value); - break; - case NewPlanScalableMatrixWithTieredPricingPrice value: - newPlanScalableMatrixWithTieredPricing(value); - break; - case NewPlanCumulativeGroupedBulkPrice value: - newPlanCumulativeGroupedBulk(value); - break; - case ReplacePricePriceCumulativeGroupedAllocation value: - cumulativeGroupedAllocation(value); - break; - case ReplacePricePriceMinimum value: - minimum(value); - break; - case NewPlanMinimumCompositePrice value: - newPlanMinimumComposite(value); - break; - case ReplacePricePricePercent value: - percent(value); - break; - case ReplacePricePriceEventOutput value: - eventOutput(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ); - } - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (NewPlanUnitPrice value) => {...}, - /// (NewPlanTieredPrice value) => {...}, - /// (NewPlanBulkPrice value) => {...}, - /// (ReplacePricePriceBulkWithFilters value) => {...}, - /// (NewPlanPackagePrice value) => {...}, - /// (NewPlanMatrixPrice value) => {...}, - /// (NewPlanThresholdTotalAmountPrice value) => {...}, - /// (NewPlanTieredPackagePrice value) => {...}, - /// (NewPlanTieredWithMinimumPrice value) => {...}, - /// (NewPlanGroupedTieredPrice value) => {...}, - /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, - /// (NewPlanPackageWithAllocationPrice value) => {...}, - /// (NewPlanUnitWithPercentPrice value) => {...}, - /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (ReplacePricePriceTieredWithProration value) => {...}, - /// (NewPlanUnitWithProrationPrice value) => {...}, - /// (NewPlanGroupedAllocationPrice value) => {...}, - /// (NewPlanBulkWithProrationPrice value) => {...}, - /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, - /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (ReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, - /// (NewPlanGroupedTieredPackagePrice value) => {...}, - /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, - /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, - /// (ReplacePricePriceCumulativeGroupedAllocation value) => {...}, - /// (ReplacePricePriceMinimum value) => {...}, - /// (NewPlanMinimumCompositePrice value) => {...}, - /// (ReplacePricePricePercent value) => {...}, - /// (ReplacePricePriceEventOutput value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func newPlanUnit, - System::Func newPlanTiered, - System::Func newPlanBulk, - System::Func bulkWithFilters, - System::Func newPlanPackage, - System::Func newPlanMatrix, - System::Func newPlanThresholdTotalAmount, - System::Func newPlanTieredPackage, - System::Func newPlanTieredWithMinimum, - System::Func newPlanGroupedTiered, - System::Func newPlanTieredPackageWithMinimum, - System::Func newPlanPackageWithAllocation, - System::Func newPlanUnitWithPercent, - System::Func newPlanMatrixWithAllocation, - System::Func tieredWithProration, - System::Func newPlanUnitWithProration, - System::Func newPlanGroupedAllocation, - System::Func newPlanBulkWithProration, - System::Func newPlanGroupedWithProratedMinimum, - System::Func newPlanGroupedWithMeteredMinimum, - System::Func groupedWithMinMaxThresholds, - System::Func newPlanMatrixWithDisplayName, - System::Func newPlanGroupedTieredPackage, - System::Func newPlanMaxGroupTieredPackage, - System::Func< - NewPlanScalableMatrixWithUnitPricingPrice, - T - > newPlanScalableMatrixWithUnitPricing, - System::Func< - NewPlanScalableMatrixWithTieredPricingPrice, - T - > newPlanScalableMatrixWithTieredPricing, - System::Func newPlanCumulativeGroupedBulk, - System::Func cumulativeGroupedAllocation, - System::Func minimum, - System::Func newPlanMinimumComposite, - System::Func percent, - System::Func eventOutput - ) - { - return this.Value switch - { - NewPlanUnitPrice value => newPlanUnit(value), - NewPlanTieredPrice value => newPlanTiered(value), - NewPlanBulkPrice value => newPlanBulk(value), - ReplacePricePriceBulkWithFilters value => bulkWithFilters(value), - NewPlanPackagePrice value => newPlanPackage(value), - NewPlanMatrixPrice value => newPlanMatrix(value), - NewPlanThresholdTotalAmountPrice value => newPlanThresholdTotalAmount(value), - NewPlanTieredPackagePrice value => newPlanTieredPackage(value), - NewPlanTieredWithMinimumPrice value => newPlanTieredWithMinimum(value), - NewPlanGroupedTieredPrice value => newPlanGroupedTiered(value), - NewPlanTieredPackageWithMinimumPrice value => newPlanTieredPackageWithMinimum(value), - NewPlanPackageWithAllocationPrice value => newPlanPackageWithAllocation(value), - NewPlanUnitWithPercentPrice value => newPlanUnitWithPercent(value), - NewPlanMatrixWithAllocationPrice value => newPlanMatrixWithAllocation(value), - ReplacePricePriceTieredWithProration value => tieredWithProration(value), - NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), - NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), - NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), - NewPlanGroupedWithProratedMinimumPrice value => newPlanGroupedWithProratedMinimum( - value - ), - NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), - ReplacePricePriceGroupedWithMinMaxThresholds value => groupedWithMinMaxThresholds( - value - ), - NewPlanMatrixWithDisplayNamePrice value => newPlanMatrixWithDisplayName(value), - NewPlanGroupedTieredPackagePrice value => newPlanGroupedTieredPackage(value), - NewPlanMaxGroupTieredPackagePrice value => newPlanMaxGroupTieredPackage(value), - NewPlanScalableMatrixWithUnitPricingPrice value => newPlanScalableMatrixWithUnitPricing( - value - ), - NewPlanScalableMatrixWithTieredPricingPrice value => - newPlanScalableMatrixWithTieredPricing(value), - NewPlanCumulativeGroupedBulkPrice value => newPlanCumulativeGroupedBulk(value), - ReplacePricePriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation( - value - ), - ReplacePricePriceMinimum value => minimum(value), - NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), - ReplacePricePricePercent value => percent(value), - ReplacePricePriceEventOutput value => eventOutput(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ), - }; - } - - public static implicit operator ReplacePricePrice(NewPlanUnitPrice value) => new(value); - - public static implicit operator ReplacePricePrice(NewPlanTieredPrice value) => new(value); - - public static implicit operator ReplacePricePrice(NewPlanBulkPrice value) => new(value); - - public static implicit operator ReplacePricePrice(ReplacePricePriceBulkWithFilters value) => - new(value); - - public static implicit operator ReplacePricePrice(NewPlanPackagePrice value) => new(value); - - public static implicit operator ReplacePricePrice(NewPlanMatrixPrice value) => new(value); - - public static implicit operator ReplacePricePrice(NewPlanThresholdTotalAmountPrice value) => - new(value); - - public static implicit operator ReplacePricePrice(NewPlanTieredPackagePrice value) => - new(value); - - public static implicit operator ReplacePricePrice(NewPlanTieredWithMinimumPrice value) => - new(value); - - public static implicit operator ReplacePricePrice(NewPlanGroupedTieredPrice value) => - new(value); - - public static implicit operator ReplacePricePrice(NewPlanTieredPackageWithMinimumPrice value) => - new(value); - - public static implicit operator ReplacePricePrice(NewPlanPackageWithAllocationPrice value) => - new(value); - - public static implicit operator ReplacePricePrice(NewPlanUnitWithPercentPrice value) => - new(value); - - public static implicit operator ReplacePricePrice(NewPlanMatrixWithAllocationPrice value) => - new(value); - - public static implicit operator ReplacePricePrice(ReplacePricePriceTieredWithProration value) => - new(value); - - public static implicit operator ReplacePricePrice(NewPlanUnitWithProrationPrice value) => - new(value); - - public static implicit operator ReplacePricePrice(NewPlanGroupedAllocationPrice value) => - new(value); - - public static implicit operator ReplacePricePrice(NewPlanBulkWithProrationPrice value) => - new(value); - - public static implicit operator ReplacePricePrice( - NewPlanGroupedWithProratedMinimumPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewPlanGroupedWithMeteredMinimumPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - ReplacePricePriceGroupedWithMinMaxThresholds value - ) => new(value); - - public static implicit operator ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice value) => - new(value); - - public static implicit operator ReplacePricePrice(NewPlanGroupedTieredPackagePrice value) => - new(value); - - public static implicit operator ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value) => - new(value); - - public static implicit operator ReplacePricePrice( - NewPlanScalableMatrixWithUnitPricingPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewPlanScalableMatrixWithTieredPricingPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice(NewPlanCumulativeGroupedBulkPrice value) => - new(value); - - public static implicit operator ReplacePricePrice( - ReplacePricePriceCumulativeGroupedAllocation value - ) => new(value); - - public static implicit operator ReplacePricePrice(ReplacePricePriceMinimum value) => new(value); - - public static implicit operator ReplacePricePrice(NewPlanMinimumCompositePrice value) => - new(value); - - public static implicit operator ReplacePricePrice(ReplacePricePricePercent value) => new(value); - - public static implicit operator ReplacePricePrice(ReplacePricePriceEventOutput value) => - new(value); - - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() - { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ); - } - this.Switch( - (newPlanUnit) => newPlanUnit.Validate(), - (newPlanTiered) => newPlanTiered.Validate(), - (newPlanBulk) => newPlanBulk.Validate(), - (bulkWithFilters) => bulkWithFilters.Validate(), - (newPlanPackage) => newPlanPackage.Validate(), - (newPlanMatrix) => newPlanMatrix.Validate(), - (newPlanThresholdTotalAmount) => newPlanThresholdTotalAmount.Validate(), - (newPlanTieredPackage) => newPlanTieredPackage.Validate(), - (newPlanTieredWithMinimum) => newPlanTieredWithMinimum.Validate(), - (newPlanGroupedTiered) => newPlanGroupedTiered.Validate(), - (newPlanTieredPackageWithMinimum) => newPlanTieredPackageWithMinimum.Validate(), - (newPlanPackageWithAllocation) => newPlanPackageWithAllocation.Validate(), - (newPlanUnitWithPercent) => newPlanUnitWithPercent.Validate(), - (newPlanMatrixWithAllocation) => newPlanMatrixWithAllocation.Validate(), - (tieredWithProration) => tieredWithProration.Validate(), - (newPlanUnitWithProration) => newPlanUnitWithProration.Validate(), - (newPlanGroupedAllocation) => newPlanGroupedAllocation.Validate(), - (newPlanBulkWithProration) => newPlanBulkWithProration.Validate(), - (newPlanGroupedWithProratedMinimum) => newPlanGroupedWithProratedMinimum.Validate(), - (newPlanGroupedWithMeteredMinimum) => newPlanGroupedWithMeteredMinimum.Validate(), - (groupedWithMinMaxThresholds) => groupedWithMinMaxThresholds.Validate(), - (newPlanMatrixWithDisplayName) => newPlanMatrixWithDisplayName.Validate(), - (newPlanGroupedTieredPackage) => newPlanGroupedTieredPackage.Validate(), - (newPlanMaxGroupTieredPackage) => newPlanMaxGroupTieredPackage.Validate(), - (newPlanScalableMatrixWithUnitPricing) => - newPlanScalableMatrixWithUnitPricing.Validate(), - (newPlanScalableMatrixWithTieredPricing) => - newPlanScalableMatrixWithTieredPricing.Validate(), - (newPlanCumulativeGroupedBulk) => newPlanCumulativeGroupedBulk.Validate(), - (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), - (newPlanMinimumComposite) => newPlanMinimumComposite.Validate(), - (percent) => percent.Validate(), - (eventOutput) => eventOutput.Validate() - ); - } - - public virtual bool Equals(ReplacePricePrice? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } - - public override int GetHashCode() - { - return 0; - } - - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class ReplacePricePriceConverter : JsonConverter -{ - public override ReplacePricePrice? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - string? modelType; - try - { - modelType = element.GetProperty("model_type").GetString(); - } - catch - { - modelType = null; - } - - switch (modelType) - { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "bulk": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "bulk_with_filters": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "package": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "matrix": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "threshold_total_amount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_package": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_with_minimum": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_package_with_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "package_with_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "unit_with_percent": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "matrix_with_allocation": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_with_proration": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "unit_with_proration": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_allocation": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "bulk_with_proration": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_prorated_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_metered_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_min_max_thresholds": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "matrix_with_display_name": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_tiered_package": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "max_group_tiered_package": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "scalable_matrix_with_unit_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "scalable_matrix_with_tiered_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "cumulative_grouped_bulk": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "cumulative_grouped_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum_composite": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "percent": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "event_output": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new ReplacePricePrice(element); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - ReplacePricePrice? value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value?.Json, options); - } -} - -[JsonConverter( - typeof(JsonModelConverter< - ReplacePricePriceBulkWithFilters, - ReplacePricePriceBulkWithFiltersFromRaw - >) -)] -public sealed record class ReplacePricePriceBulkWithFilters : JsonModel -{ - /// - /// Configuration for bulk_with_filters pricing - /// - public required ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "bulk_with_filters_config" - ); - } - init { this._rawData.Set("bulk_with_filters_config", value); } - } - - /// - /// The cadence to bill for this price on. - /// - public required ApiEnum Cadence - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); - } - init { this._rawData.Set("cadence", value); } - } - - /// - /// The id of the item the price will be associated with. - /// - public required string ItemID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); - } - init { this._rawData.Set("item_id", value); } - } - - /// - /// The pricing model type - /// - public JsonElement ModelType - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); - } - init { this._rawData.Set("model_type", value); } - } - - /// - /// The name of the price. - /// - public required string Name - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } - } - - /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. - /// - public string? BillableMetricID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); - } - init { this._rawData.Set("billable_metric_id", value); } - } - - /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. - /// - public bool? BilledInAdvance - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); - } - init { this._rawData.Set("billed_in_advance", value); } - } - - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } - } - - /// - /// The per unit conversion rate of the price currency to the invoicing currency. - /// - public double? ConversionRate - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); - } - init { this._rawData.Set("conversion_rate", value); } - } - - /// - /// The configuration for the rate of the price currency to the invoicing currency. - /// - public ReplacePricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", value); } - } - - /// - /// An ISO 4217 currency string, or custom pricing unit identifier, in which - /// this price is billed. - /// - public string? Currency - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("currency"); - } - init { this._rawData.Set("currency", value); } - } - - /// - /// For dimensional price: specifies a price group and dimension values - /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } - } - - /// - /// An alias for the price. - /// - public string? ExternalPriceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } - } - - /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. - /// - public double? FixedPriceQuantity - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } - } - - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", value); } - } - - /// - /// Within each billing cycle, specifies the cadence at which invoices are produced. - /// If unspecified, a single invoice is produced per billing cycle. - /// - public NewBillingCycleConfiguration? InvoicingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); - } - init { this._rawData.Set("invoicing_cycle_configuration", value); } - } - - /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared - /// by setting `metadata` to `null`. - /// - public IReadOnlyDictionary? Metadata - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) - ); - } - } - - /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. - /// - public string? ReferenceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("reference_id"); - } - init { this._rawData.Set("reference_id", value); } - } - - /// - public override void Validate() - { - this.BulkWithFiltersConfig.Validate(); - this.Cadence.Validate(); - _ = this.ItemID; - if ( - !JsonElement.DeepEquals( - this.ModelType, - JsonSerializer.SerializeToElement("bulk_with_filters") - ) - ) - { - throw new OrbInvalidDataException("Invalid value given for constant"); - } - _ = this.Name; - _ = this.BillableMetricID; - _ = this.BilledInAdvance; - this.BillingCycleConfiguration?.Validate(); - _ = this.ConversionRate; - this.ConversionRateConfig?.Validate(); - _ = this.Currency; - this.DimensionalPriceConfiguration?.Validate(); - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.InvoiceGroupingKey; - this.InvoicingCycleConfiguration?.Validate(); - _ = this.Metadata; - _ = this.ReferenceID; - } - - public ReplacePricePriceBulkWithFilters() - { - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - } - - public ReplacePricePriceBulkWithFilters( - ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters - ) - : base(replacePricePriceBulkWithFilters) { } - - public ReplacePricePriceBulkWithFilters(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceBulkWithFilters(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static ReplacePricePriceBulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class ReplacePricePriceBulkWithFiltersFromRaw : IFromRawJson -{ - /// - public ReplacePricePriceBulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFilters.FromRawUnchecked(rawData); -} - -/// -/// Configuration for bulk_with_filters pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw - >) -)] -public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig : JsonModel -{ - /// - /// Property filters to apply (all must match) - /// - public required IReadOnlyList Filters - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("filters"); - } - init - { - this._rawData.Set< - ImmutableArray - >("filters", ImmutableArray.ToImmutableArray(value)); - } - } - - /// - /// Bulk tiers for rating based on total usage volume - /// - public required IReadOnlyList Tiers - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); - } - init - { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); - } - } - - /// - public override void Validate() - { - foreach (var item in this.Filters) - { - item.Validate(); - } - foreach (var item in this.Tiers) - { - item.Validate(); - } - } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig - ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfig) { } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw - : IFromRawJson -{ - /// - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked(rawData); -} - -/// -/// Configuration for a single property filter -/// -[JsonConverter( - typeof(JsonModelConverter< - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter, - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw - >) -)] -public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter : JsonModel -{ - /// - /// Event property key to filter on - /// - public required string PropertyKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_key"); - } - init { this._rawData.Set("property_key", value); } - } - - /// - /// Event property value to match - /// - public required string PropertyValue - { - get + var element = JsonSerializer.Deserialize(ref reader, options); + string? modelType; + try { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_value"); + modelType = element.GetProperty("model_type").GetString(); } - init { this._rawData.Set("property_value", value); } - } - - /// - public override void Validate() - { - _ = this.PropertyKey; - _ = this.PropertyValue; - } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw - : IFromRawJson -{ - /// - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( - IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked(rawData); -} - -/// -/// Configuration for a single bulk pricing tier -/// -[JsonConverter( - typeof(JsonModelConverter< - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier, - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw - >) -)] -public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier : JsonModel -{ - /// - /// Amount per unit - /// - public required string UnitAmount - { - get + catch { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + modelType = null; } - init { this._rawData.Set("unit_amount", value); } - } - /// - /// The lower bound for this tier - /// - public string? TierLowerBound - { - get + switch (modelType) { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("tier_lower_bound"); - } - init { this._rawData.Set("tier_lower_bound", value); } - } + case "unit": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - public override void Validate() - { - _ = this.UnitAmount; - _ = this.TierLowerBound; - } + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } + return new(element); + } + case "bulk": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } + return new(element); + } + case "bulk_with_filters": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } + return new(element); + } + case "package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 + return new(element); + } + case "matrix": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } + return new(element); + } + case "threshold_total_amount": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - [SetsRequiredMembers] - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier(string unitAmount) - : this() - { - this.UnitAmount = unitAmount; - } -} + return new(element); + } + case "tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw - : IFromRawJson -{ - /// - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked(rawData); -} + return new(element); + } + case "tiered_with_minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersCadenceConverter))] -public enum ReplacePricePriceBulkWithFiltersCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} + return new(element); + } + case "grouped_tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -sealed class ReplacePricePriceBulkWithFiltersCadenceConverter - : JsonConverter -{ - public override ReplacePricePriceBulkWithFiltersCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => ReplacePricePriceBulkWithFiltersCadence.Annual, - "semi_annual" => ReplacePricePriceBulkWithFiltersCadence.SemiAnnual, - "monthly" => ReplacePricePriceBulkWithFiltersCadence.Monthly, - "quarterly" => ReplacePricePriceBulkWithFiltersCadence.Quarterly, - "one_time" => ReplacePricePriceBulkWithFiltersCadence.OneTime, - "custom" => ReplacePricePriceBulkWithFiltersCadence.Custom, - _ => (ReplacePricePriceBulkWithFiltersCadence)(-1), - }; - } + return new(element); + } + case "tiered_package_with_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public override void Write( - Utf8JsonWriter writer, - ReplacePricePriceBulkWithFiltersCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch + return new(element); + } + case "package_with_allocation": { - ReplacePricePriceBulkWithFiltersCadence.Annual => "annual", - ReplacePricePriceBulkWithFiltersCadence.SemiAnnual => "semi_annual", - ReplacePricePriceBulkWithFiltersCadence.Monthly => "monthly", - ReplacePricePriceBulkWithFiltersCadence.Quarterly => "quarterly", - ReplacePricePriceBulkWithFiltersCadence.OneTime => "one_time", - ReplacePricePriceBulkWithFiltersCadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersConversionRateConfigConverter))] -public record class ReplacePricePriceBulkWithFiltersConversionRateConfig : ModelBase -{ - public object? Value { get; } = null; + return new(element); + } + case "unit_with_percent": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - JsonElement? _element = null; + return new(element); + } + case "matrix_with_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public JsonElement Json - { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } - } + return new(element); + } + case "tiered_with_proration": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + return new(element); + } + case "unit_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + return new(element); + } + case "grouped_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) - { - this._element = element; - } + return new(element); + } + case "bulk_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) - { - value = this.Value as SharedUnitConversionRateConfig; - return value != null; - } + return new(element); + } + case "grouped_with_prorated_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) - { - value = this.Value as SharedTieredConversionRateConfig; - return value != null; - } + return new(element); + } + case "grouped_with_metered_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action unit, - System::Action tiered - ) - { - switch (this.Value) - { - case SharedUnitConversionRateConfig value: - unit(value); - break; - case SharedTieredConversionRateConfig value: - tiered(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" - ); - } - } + return new(element); + } + case "grouped_with_min_max_thresholds": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func unit, - System::Func tiered - ) - { - return this.Value switch - { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" - ), - }; - } + return new(element); + } + case "matrix_with_display_name": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); + return new(element); + } + case "grouped_tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); + return new(element); + } + case "max_group_tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() - { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" - ); - } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); - } + return new(element); + } + case "scalable_matrix_with_unit_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public virtual bool Equals(ReplacePricePriceBulkWithFiltersConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + return new(element); + } + case "scalable_matrix_with_tiered_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public override int GetHashCode() - { - return 0; - } + return new(element); + } + case "cumulative_grouped_bulk": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} + return new(element); + } + case "cumulative_grouped_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -sealed class ReplacePricePriceBulkWithFiltersConversionRateConfigConverter - : JsonConverter -{ - public override ReplacePricePriceBulkWithFiltersConversionRateConfig? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; - try - { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); - } - catch - { - conversionRateType = null; - } + return new(element); + } + case "minimum_composite": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - switch (conversionRateType) - { - case "unit": + return new(element); + } + case "percent": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -13860,11 +11778,11 @@ JsonSerializerOptions options return new(element); } - case "tiered": + case "event_output": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -13884,39 +11802,54 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceBulkWithFiltersConversionRateConfig(element); + return new ReplacePricePrice(element); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceBulkWithFiltersConversionRateConfig value, + ReplacePricePrice? value, JsonSerializerOptions options ) { - JsonSerializer.Serialize(writer, value.Json, options); + JsonSerializer.Serialize(writer, value?.Json, options); } } [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceTieredWithProration, - ReplacePricePriceTieredWithProrationFromRaw + ReplacePricePriceBulkWithFilters, + ReplacePricePriceBulkWithFiltersFromRaw >) )] -public sealed record class ReplacePricePriceTieredWithProration : JsonModel +public sealed record class ReplacePricePriceBulkWithFilters : JsonModel { + /// + /// Configuration for bulk_with_filters pricing + /// + public required ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "bulk_with_filters_config" + ); + } + init { this._rawData.Set("bulk_with_filters_config", value); } + } + /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -13961,21 +11894,6 @@ public required string Name init { this._rawData.Set("name", value); } } - /// - /// Configuration for tiered_with_proration pricing - /// - public required ReplacePricePriceTieredWithProrationTieredWithProrationConfig TieredWithProrationConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "tiered_with_proration_config" - ); - } - init { this._rawData.Set("tiered_with_proration_config", value); } - } - /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -14035,12 +11953,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public ReplacePricePriceTieredWithProrationConversionRateConfig? ConversionRateConfig + public ReplacePricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -14169,19 +12087,19 @@ public string? ReferenceID /// public override void Validate() { + this.BulkWithFiltersConfig.Validate(); this.Cadence.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("tiered_with_proration") + JsonSerializer.SerializeToElement("bulk_with_filters") ) ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.TieredWithProrationConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -14197,33 +12115,138 @@ public override void Validate() _ = this.ReferenceID; } - public ReplacePricePriceTieredWithProration() + public ReplacePricePriceBulkWithFilters() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } - public ReplacePricePriceTieredWithProration( - ReplacePricePriceTieredWithProration replacePricePriceTieredWithProration + public ReplacePricePriceBulkWithFilters( + ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters ) - : base(replacePricePriceTieredWithProration) { } + : base(replacePricePriceBulkWithFilters) { } + + public ReplacePricePriceBulkWithFilters(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceBulkWithFilters(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePricePriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePricePriceBulkWithFiltersFromRaw : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFilters.FromRawUnchecked(rawData); +} + +/// +/// Configuration for bulk_with_filters pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + >) +)] +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig : JsonModel +{ + /// + /// Property filters to apply (all must match) + /// + public required IReadOnlyList Filters + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("filters"); + } + init + { + this._rawData.Set< + ImmutableArray + >("filters", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// Bulk tiers for rating based on total usage volume + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + public override void Validate() + { + foreach (var item in this.Filters) + { + item.Validate(); + } + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } + + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig + ) + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfig) { } - public ReplacePricePriceTieredWithProration(IReadOnlyDictionary rawData) + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProration(FrozenDictionary rawData) + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceTieredWithProration FromRawUnchecked( + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -14231,124 +12254,67 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceTieredWithProrationFromRaw - : IFromRawJson +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + : IFromRawJson { /// - public ReplacePricePriceTieredWithProration FromRawUnchecked( + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceTieredWithProration.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(ReplacePricePriceTieredWithProrationCadenceConverter))] -public enum ReplacePricePriceTieredWithProrationCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class ReplacePricePriceTieredWithProrationCadenceConverter - : JsonConverter -{ - public override ReplacePricePriceTieredWithProrationCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => ReplacePricePriceTieredWithProrationCadence.Annual, - "semi_annual" => ReplacePricePriceTieredWithProrationCadence.SemiAnnual, - "monthly" => ReplacePricePriceTieredWithProrationCadence.Monthly, - "quarterly" => ReplacePricePriceTieredWithProrationCadence.Quarterly, - "one_time" => ReplacePricePriceTieredWithProrationCadence.OneTime, - "custom" => ReplacePricePriceTieredWithProrationCadence.Custom, - _ => (ReplacePricePriceTieredWithProrationCadence)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - ReplacePricePriceTieredWithProrationCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - ReplacePricePriceTieredWithProrationCadence.Annual => "annual", - ReplacePricePriceTieredWithProrationCadence.SemiAnnual => "semi_annual", - ReplacePricePriceTieredWithProrationCadence.Monthly => "monthly", - ReplacePricePriceTieredWithProrationCadence.Quarterly => "quarterly", - ReplacePricePriceTieredWithProrationCadence.OneTime => "one_time", - ReplacePricePriceTieredWithProrationCadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked(rawData); } /// -/// Configuration for tiered_with_proration pricing +/// Configuration for a single property filter /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceTieredWithProrationTieredWithProrationConfig, - ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw >) )] -public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfig : JsonModel +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter : JsonModel { /// - /// Tiers for rating based on total usage quantities into the specified tier - /// with proration + /// Event property key to filter on /// - public required IReadOnlyList Tiers + public required string PropertyKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + return this._rawData.GetNotNullClass("property_key"); } - init + init { this._rawData.Set("property_key", value); } + } + + /// + /// Event property value to match + /// + public required string PropertyValue + { + get { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("property_value"); } + init { this._rawData.Set("property_value", value); } } /// public override void Validate() { - foreach (var item in this.Tiers) - { - item.Validate(); - } + _ = this.PropertyKey; + _ = this.PropertyValue; } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig() { } + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( - ReplacePricePriceTieredWithProrationTieredWithProrationConfig replacePricePriceTieredWithProrationTieredWithProrationConfig + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter ) - : base(replacePricePriceTieredWithProrationTieredWithProrationConfig) { } + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( IReadOnlyDictionary rawData ) { @@ -14357,7 +12323,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( FrozenDictionary rawData ) { @@ -14365,86 +12331,76 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( - IReadOnlyList tiers - ) - : this() - { - this.Tiers = tiers; - } } -class ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw - : IFromRawJson +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + : IFromRawJson { /// - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked(rawData); + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked(rawData); } /// -/// Configuration for a single tiered with proration tier +/// Configuration for a single bulk pricing tier /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier, - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw >) )] -public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier - : JsonModel +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier : JsonModel { /// - /// Inclusive tier starting value + /// Amount per unit /// - public required string TierLowerBound + public required string UnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("unit_amount"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("unit_amount", value); } } /// - /// Amount per unit + /// The lower bound for this tier /// - public required string UnitAmount + public string? TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNullableClass("tier_lower_bound"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("tier_lower_bound", value); } } /// public override void Validate() { - _ = this.TierLowerBound; _ = this.UnitAmount; + _ = this.TierLowerBound; } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() { } + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier replacePricePriceTieredWithProrationTieredWithProrationConfigTier + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier ) - : base(replacePricePriceTieredWithProrationTieredWithProrationConfigTier) { } + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( IReadOnlyDictionary rawData ) { @@ -14453,7 +12409,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( FrozenDictionary rawData ) { @@ -14461,27 +12417,93 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier(string unitAmount) + : this() + { + this.UnitAmount = unitAmount; + } +} + +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersCadenceConverter))] +public enum ReplacePricePriceBulkWithFiltersCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePricePriceBulkWithFiltersCadenceConverter + : JsonConverter +{ + public override ReplacePricePriceBulkWithFiltersCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePricePriceBulkWithFiltersCadence.Annual, + "semi_annual" => ReplacePricePriceBulkWithFiltersCadence.SemiAnnual, + "monthly" => ReplacePricePriceBulkWithFiltersCadence.Monthly, + "quarterly" => ReplacePricePriceBulkWithFiltersCadence.Quarterly, + "one_time" => ReplacePricePriceBulkWithFiltersCadence.OneTime, + "custom" => ReplacePricePriceBulkWithFiltersCadence.Custom, + _ => (ReplacePricePriceBulkWithFiltersCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePricePriceBulkWithFiltersCadence value, + JsonSerializerOptions options ) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePricePriceBulkWithFiltersCadence.Annual => "annual", + ReplacePricePriceBulkWithFiltersCadence.SemiAnnual => "semi_annual", + ReplacePricePriceBulkWithFiltersCadence.Monthly => "monthly", + ReplacePricePriceBulkWithFiltersCadence.Quarterly => "quarterly", + ReplacePricePriceBulkWithFiltersCadence.OneTime => "one_time", + ReplacePricePriceBulkWithFiltersCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); } } -class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw - : IFromRawJson -{ - /// - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked(rawData); -} - -[JsonConverter(typeof(ReplacePricePriceTieredWithProrationConversionRateConfigConverter))] -public record class ReplacePricePriceTieredWithProrationConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersConversionRateConfigConverter))] +public record class ReplacePricePriceBulkWithFiltersConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -14498,7 +12520,7 @@ public JsonElement Json } } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -14507,7 +12529,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -14516,7 +12538,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) + public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) { this._element = element; } @@ -14598,7 +12620,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" ); } } @@ -14634,16 +12656,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -14662,13 +12684,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ReplacePricePriceTieredWithProrationConversionRateConfig? other) + public virtual bool Equals(ReplacePricePriceBulkWithFiltersConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -14682,10 +12704,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class ReplacePricePriceTieredWithProrationConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceBulkWithFiltersConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceTieredWithProrationConversionRateConfig? Read( + public override ReplacePricePriceBulkWithFiltersConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -14750,14 +12772,14 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceTieredWithProrationConversionRateConfig(element); + return new ReplacePricePriceBulkWithFiltersConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceTieredWithProrationConversionRateConfig value, + ReplacePricePriceBulkWithFiltersConversionRateConfig value, JsonSerializerOptions options ) { @@ -14767,42 +12789,27 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceGroupedWithMinMaxThresholds, - ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + ReplacePricePriceTieredWithProration, + ReplacePricePriceTieredWithProrationFromRaw >) )] -public sealed record class ReplacePricePriceGroupedWithMinMaxThresholds : JsonModel +public sealed record class ReplacePricePriceTieredWithProration : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } } - /// - /// Configuration for grouped_with_min_max_thresholds pricing - /// - public required ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_with_min_max_thresholds_config" - ); - } - init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } - } - /// /// The id of the item the price will be associated with. /// @@ -14842,6 +12849,21 @@ public required string Name init { this._rawData.Set("name", value); } } + /// + /// Configuration for tiered_with_proration pricing + /// + public required ReplacePricePriceTieredWithProrationTieredWithProrationConfig TieredWithProrationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "tiered_with_proration_config" + ); + } + init { this._rawData.Set("tiered_with_proration_config", value); } + } + /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -14901,12 +12923,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + public ReplacePricePriceTieredWithProrationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -15036,18 +13058,18 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.GroupedWithMinMaxThresholdsConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + JsonSerializer.SerializeToElement("tiered_with_proration") ) ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; + this.TieredWithProrationConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -15063,35 +13085,33 @@ public override void Validate() _ = this.ReferenceID; } - public ReplacePricePriceGroupedWithMinMaxThresholds() + public ReplacePricePriceTieredWithProration() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } - public ReplacePricePriceGroupedWithMinMaxThresholds( - ReplacePricePriceGroupedWithMinMaxThresholds replacePricePriceGroupedWithMinMaxThresholds + public ReplacePricePriceTieredWithProration( + ReplacePricePriceTieredWithProration replacePricePriceTieredWithProration ) - : base(replacePricePriceGroupedWithMinMaxThresholds) { } + : base(replacePricePriceTieredWithProration) { } - public ReplacePricePriceGroupedWithMinMaxThresholds( - IReadOnlyDictionary rawData - ) + public ReplacePricePriceTieredWithProration(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholds(FrozenDictionary rawData) + ReplacePricePriceTieredWithProration(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15099,20 +13119,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class ReplacePricePriceTieredWithProrationFromRaw + : IFromRawJson { /// - public ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + public ReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + ) => ReplacePricePriceTieredWithProration.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter))] -public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(ReplacePricePriceTieredWithProrationCadenceConverter))] +public enum ReplacePricePriceTieredWithProrationCadence { Annual, SemiAnnual, @@ -15122,10 +13142,10 @@ public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence Custom, } -sealed class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class ReplacePricePriceTieredWithProrationCadenceConverter + : JsonConverter { - public override ReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( + public override ReplacePricePriceTieredWithProrationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -15133,122 +13153,186 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - "semi_annual" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual, - "monthly" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly, - "quarterly" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly, - "one_time" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime, - "custom" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom, - _ => (ReplacePricePriceGroupedWithMinMaxThresholdsCadence)(-1), + "annual" => ReplacePricePriceTieredWithProrationCadence.Annual, + "semi_annual" => ReplacePricePriceTieredWithProrationCadence.SemiAnnual, + "monthly" => ReplacePricePriceTieredWithProrationCadence.Monthly, + "quarterly" => ReplacePricePriceTieredWithProrationCadence.Quarterly, + "one_time" => ReplacePricePriceTieredWithProrationCadence.OneTime, + "custom" => ReplacePricePriceTieredWithProrationCadence.Custom, + _ => (ReplacePricePriceTieredWithProrationCadence)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - ReplacePricePriceGroupedWithMinMaxThresholdsCadence value, - JsonSerializerOptions options + public override void Write( + Utf8JsonWriter writer, + ReplacePricePriceTieredWithProrationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePricePriceTieredWithProrationCadence.Annual => "annual", + ReplacePricePriceTieredWithProrationCadence.SemiAnnual => "semi_annual", + ReplacePricePriceTieredWithProrationCadence.Monthly => "monthly", + ReplacePricePriceTieredWithProrationCadence.Quarterly => "quarterly", + ReplacePricePriceTieredWithProrationCadence.OneTime => "one_time", + ReplacePricePriceTieredWithProrationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for tiered_with_proration pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceTieredWithProrationTieredWithProrationConfig, + ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw + >) +)] +public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfig : JsonModel +{ + /// + /// Tiers for rating based on total usage quantities into the specified tier + /// with proration + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + public override void Validate() + { + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig() { } + + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + ReplacePricePriceTieredWithProrationTieredWithProrationConfig replacePricePriceTieredWithProrationTieredWithProrationConfig + ) + : base(replacePricePriceTieredWithProrationTieredWithProrationConfig) { } + + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyList tiers ) + : this() { - JsonSerializer.Serialize( - writer, - value switch - { - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual => "annual", - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly => "monthly", - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime => "one_time", - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); + this.Tiers = tiers; } } +class ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked(rawData); +} + /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for a single tiered with proration tier /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier, + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw >) )] -public sealed record class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig +public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier : JsonModel { /// - /// The event property used to group before applying thresholds - /// - public required string GroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); - } - init { this._rawData.Set("grouping_key", value); } - } - - /// - /// The maximum amount to charge each group - /// - public required string MaximumCharge - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); - } - init { this._rawData.Set("maximum_charge", value); } - } - - /// - /// The minimum amount to charge each group, regardless of usage + /// Inclusive tier starting value /// - public required string MinimumCharge + public required string TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullClass("tier_lower_bound"); } - init { this._rawData.Set("minimum_charge", value); } + init { this._rawData.Set("tier_lower_bound", value); } } /// - /// The base price charged per group + /// Amount per unit /// - public required string PerUnitRate + public required string UnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("per_unit_rate"); + return this._rawData.GetNotNullClass("unit_amount"); } - init { this._rawData.Set("per_unit_rate", value); } + init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + _ = this.TierLowerBound; + _ = this.UnitAmount; } - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() { } - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier replacePricePriceTieredWithProrationTieredWithProrationConfigTier ) - : base(replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } + : base(replacePricePriceTieredWithProrationTieredWithProrationConfigTier) { } - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( IReadOnlyDictionary rawData ) { @@ -15257,7 +13341,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( FrozenDictionary rawData ) { @@ -15265,8 +13349,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15274,20 +13358,18 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + : IFromRawJson { /// - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) => - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( - rawData - ); + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked(rawData); } -[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter))] -public record class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceTieredWithProrationConversionRateConfigConverter))] +public record class ReplacePricePriceTieredWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -15304,7 +13386,7 @@ public JsonElement Json } } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15313,7 +13395,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15322,7 +13404,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -15404,7 +13486,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" ); } } @@ -15440,16 +13522,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -15468,15 +13550,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other - ) + public virtual bool Equals(ReplacePricePriceTieredWithProrationConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -15490,10 +13570,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceTieredWithProrationConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override ReplacePricePriceTieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -15558,16 +13638,14 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( - element - ); + return new ReplacePricePriceTieredWithProrationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, + ReplacePricePriceTieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -15577,40 +13655,40 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceCumulativeGroupedAllocation, - ReplacePricePriceCumulativeGroupedAllocationFromRaw + ReplacePricePriceGroupedWithMinMaxThresholds, + ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw >) )] -public sealed record class ReplacePricePriceCumulativeGroupedAllocation : JsonModel +public sealed record class ReplacePricePriceGroupedWithMinMaxThresholds : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } } /// - /// Configuration for cumulative_grouped_allocation pricing + /// Configuration for grouped_with_min_max_thresholds pricing /// - public required ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "cumulative_grouped_allocation_config" + return this._rawData.GetNotNullClass( + "grouped_with_min_max_thresholds_config" ); } - init { this._rawData.Set("cumulative_grouped_allocation_config", value); } + init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } } /// @@ -15711,12 +13789,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -15846,12 +13924,12 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.CumulativeGroupedAllocationConfig.Validate(); + this.GroupedWithMinMaxThresholdsConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") ) ) { @@ -15873,35 +13951,35 @@ public override void Validate() _ = this.ReferenceID; } - public ReplacePricePriceCumulativeGroupedAllocation() + public ReplacePricePriceGroupedWithMinMaxThresholds() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } - public ReplacePricePriceCumulativeGroupedAllocation( - ReplacePricePriceCumulativeGroupedAllocation replacePricePriceCumulativeGroupedAllocation + public ReplacePricePriceGroupedWithMinMaxThresholds( + ReplacePricePriceGroupedWithMinMaxThresholds replacePricePriceGroupedWithMinMaxThresholds ) - : base(replacePricePriceCumulativeGroupedAllocation) { } + : base(replacePricePriceGroupedWithMinMaxThresholds) { } - public ReplacePricePriceCumulativeGroupedAllocation( + public ReplacePricePriceGroupedWithMinMaxThresholds( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocation(FrozenDictionary rawData) + ReplacePricePriceGroupedWithMinMaxThresholds(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15909,20 +13987,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceCumulativeGroupedAllocationFromRaw - : IFromRawJson +class ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + : IFromRawJson { /// - public ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + public ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked(rawData); + ) => ReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationCadenceConverter))] -public enum ReplacePricePriceCumulativeGroupedAllocationCadence +[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter))] +public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence { Annual, SemiAnnual, @@ -15932,10 +14010,10 @@ public enum ReplacePricePriceCumulativeGroupedAllocationCadence Custom, } -sealed class ReplacePricePriceCumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter { - public override ReplacePricePriceCumulativeGroupedAllocationCadence Read( + public override ReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -15943,19 +14021,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - "semi_annual" => ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual, - "monthly" => ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly, - "quarterly" => ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly, - "one_time" => ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime, - "custom" => ReplacePricePriceCumulativeGroupedAllocationCadence.Custom, - _ => (ReplacePricePriceCumulativeGroupedAllocationCadence)(-1), + "annual" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + "semi_annual" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual, + "monthly" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly, + "one_time" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime, + "custom" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom, + _ => (ReplacePricePriceGroupedWithMinMaxThresholdsCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceCumulativeGroupedAllocationCadence value, + ReplacePricePriceGroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -15963,12 +14041,12 @@ JsonSerializerOptions options writer, value switch { - ReplacePricePriceCumulativeGroupedAllocationCadence.Annual => "annual", - ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", - ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly => "monthly", - ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly => "quarterly", - ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime => "one_time", - ReplacePricePriceCumulativeGroupedAllocationCadence.Custom => "custom", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual => "annual", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly => "monthly", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime => "one_time", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -15979,86 +14057,86 @@ JsonSerializerOptions options } /// -/// Configuration for cumulative_grouped_allocation pricing +/// Configuration for grouped_with_min_max_thresholds pricing /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw >) )] -public sealed record class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig +public sealed record class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig : JsonModel { /// - /// The overall allocation across all groups + /// The event property used to group before applying thresholds /// - public required string CumulativeAllocation + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("cumulative_allocation"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("cumulative_allocation", value); } + init { this._rawData.Set("grouping_key", value); } } /// - /// The allocation per individual group + /// The maximum amount to charge each group /// - public required string GroupAllocation + public required string MaximumCharge { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group_allocation"); + return this._rawData.GetNotNullClass("maximum_charge"); } - init { this._rawData.Set("group_allocation", value); } + init { this._rawData.Set("maximum_charge", value); } } /// - /// The event property used to group usage before applying allocations + /// The minimum amount to charge each group, regardless of usage /// - public required string GroupingKey + public required string MinimumCharge { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("minimum_charge"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("minimum_charge", value); } } /// - /// The amount to charge for each unit outside of the allocation + /// The base price charged per group /// - public required string UnitAmount + public required string PerUnitRate { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullClass("per_unit_rate"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("per_unit_rate", value); } } /// public override void Validate() { - _ = this.CumulativeAllocation; - _ = this.GroupAllocation; _ = this.GroupingKey; - _ = this.UnitAmount; + _ = this.MaximumCharge; + _ = this.MinimumCharge; + _ = this.PerUnitRate; } - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) - : base(replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } + : base(replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData ) { @@ -16067,7 +14145,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -16075,8 +14153,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16084,20 +14162,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + : IFromRawJson { /// - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( rawData ); } -[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter))] -public record class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter))] +public record class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -16114,7 +14192,7 @@ public JsonElement Json } } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16123,7 +14201,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16132,7 +14210,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -16214,7 +14292,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } } @@ -16250,16 +14328,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -16278,14 +14356,14 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? other + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other ) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); @@ -16300,10 +14378,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( + public override ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16368,7 +14446,7 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( element ); } @@ -16377,7 +14455,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -16386,51 +14464,54 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter) + typeof(JsonModelConverter< + ReplacePricePriceCumulativeGroupedAllocation, + ReplacePricePriceCumulativeGroupedAllocationFromRaw + >) )] -public sealed record class ReplacePricePriceMinimum : JsonModel +public sealed record class ReplacePricePriceCumulativeGroupedAllocation : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( - "cadence" - ); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); } init { this._rawData.Set("cadence", value); } } /// - /// The id of the item the price will be associated with. + /// Configuration for cumulative_grouped_allocation pricing /// - public required string ItemID + public required ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass( + "cumulative_grouped_allocation_config" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("cumulative_grouped_allocation_config", value); } } /// - /// Configuration for minimum pricing + /// The id of the item the price will be associated with. /// - public required ReplacePricePriceMinimumMinimumConfig MinimumConfig + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" - ); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("minimum_config", value); } + init { this._rawData.Set("item_id", value); } } /// @@ -16518,12 +14599,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public ReplacePricePriceMinimumConversionRateConfig? ConversionRateConfig + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -16653,9 +14734,14 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); + this.CumulativeGroupedAllocationConfig.Validate(); _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -16675,31 +14761,35 @@ public override void Validate() _ = this.ReferenceID; } - public ReplacePricePriceMinimum() + public ReplacePricePriceCumulativeGroupedAllocation() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public ReplacePricePriceMinimum(ReplacePricePriceMinimum replacePricePriceMinimum) - : base(replacePricePriceMinimum) { } + public ReplacePricePriceCumulativeGroupedAllocation( + ReplacePricePriceCumulativeGroupedAllocation replacePricePriceCumulativeGroupedAllocation + ) + : base(replacePricePriceCumulativeGroupedAllocation) { } - public ReplacePricePriceMinimum(IReadOnlyDictionary rawData) + public ReplacePricePriceCumulativeGroupedAllocation( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceMinimum(FrozenDictionary rawData) + ReplacePricePriceCumulativeGroupedAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceMinimum FromRawUnchecked( + /// + public static ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16707,19 +14797,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceMinimumFromRaw : IFromRawJson +class ReplacePricePriceCumulativeGroupedAllocationFromRaw + : IFromRawJson { /// - public ReplacePricePriceMinimum FromRawUnchecked( + public ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceMinimum.FromRawUnchecked(rawData); + ) => ReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(ReplacePricePriceMinimumCadenceConverter))] -public enum ReplacePricePriceMinimumCadence +[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationCadenceConverter))] +public enum ReplacePricePriceCumulativeGroupedAllocationCadence { Annual, SemiAnnual, @@ -16729,10 +14820,10 @@ public enum ReplacePricePriceMinimumCadence Custom, } -sealed class ReplacePricePriceMinimumCadenceConverter - : JsonConverter +sealed class ReplacePricePriceCumulativeGroupedAllocationCadenceConverter + : JsonConverter { - public override ReplacePricePriceMinimumCadence Read( + public override ReplacePricePriceCumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16740,19 +14831,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => ReplacePricePriceMinimumCadence.Annual, - "semi_annual" => ReplacePricePriceMinimumCadence.SemiAnnual, - "monthly" => ReplacePricePriceMinimumCadence.Monthly, - "quarterly" => ReplacePricePriceMinimumCadence.Quarterly, - "one_time" => ReplacePricePriceMinimumCadence.OneTime, - "custom" => ReplacePricePriceMinimumCadence.Custom, - _ => (ReplacePricePriceMinimumCadence)(-1), + "annual" => ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + "semi_annual" => ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly, + "quarterly" => ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly, + "one_time" => ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime, + "custom" => ReplacePricePriceCumulativeGroupedAllocationCadence.Custom, + _ => (ReplacePricePriceCumulativeGroupedAllocationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceMinimumCadence value, + ReplacePricePriceCumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -16760,12 +14851,12 @@ JsonSerializerOptions options writer, value switch { - ReplacePricePriceMinimumCadence.Annual => "annual", - ReplacePricePriceMinimumCadence.SemiAnnual => "semi_annual", - ReplacePricePriceMinimumCadence.Monthly => "monthly", - ReplacePricePriceMinimumCadence.Quarterly => "quarterly", - ReplacePricePriceMinimumCadence.OneTime => "one_time", - ReplacePricePriceMinimumCadence.Custom => "custom", + ReplacePricePriceCumulativeGroupedAllocationCadence.Annual => "annual", + ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", + ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly => "monthly", + ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly => "quarterly", + ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime => "one_time", + ReplacePricePriceCumulativeGroupedAllocationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -16776,104 +14867,125 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for cumulative_grouped_allocation pricing /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceMinimumMinimumConfig, - ReplacePricePriceMinimumMinimumConfigFromRaw + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw >) )] -public sealed record class ReplacePricePriceMinimumMinimumConfig : JsonModel +public sealed record class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + : JsonModel { /// - /// The minimum amount to apply + /// The overall allocation across all groups /// - public required string MinimumAmount + public required string CumulativeAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNotNullClass("cumulative_allocation"); } - init { this._rawData.Set("minimum_amount", value); } + init { this._rawData.Set("cumulative_allocation", value); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// The allocation per individual group /// - public bool? Prorated + public required string GroupAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); + return this._rawData.GetNotNullClass("group_allocation"); } - init + init { this._rawData.Set("group_allocation", value); } + } + + /// + /// The event property used to group usage before applying allocations + /// + public required string GroupingKey + { + get { - if (value == null) - { - return; - } + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } - this._rawData.Set("prorated", value); + /// + /// The amount to charge for each unit outside of the allocation + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); } + init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.MinimumAmount; - _ = this.Prorated; + _ = this.CumulativeAllocation; + _ = this.GroupAllocation; + _ = this.GroupingKey; + _ = this.UnitAmount; } - public ReplacePricePriceMinimumMinimumConfig() { } + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } - public ReplacePricePriceMinimumMinimumConfig( - ReplacePricePriceMinimumMinimumConfig replacePricePriceMinimumMinimumConfig + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) - : base(replacePricePriceMinimumMinimumConfig) { } + : base(replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } - public ReplacePricePriceMinimumMinimumConfig(IReadOnlyDictionary rawData) + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceMinimumMinimumConfig(FrozenDictionary rawData) + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + /// + public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public ReplacePricePriceMinimumMinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class ReplacePricePriceMinimumMinimumConfigFromRaw - : IFromRawJson +class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + : IFromRawJson { /// - public ReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceMinimumMinimumConfig.FromRawUnchecked(rawData); + ) => + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( + rawData + ); } -[JsonConverter(typeof(ReplacePricePriceMinimumConversionRateConfigConverter))] -public record class ReplacePricePriceMinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter))] +public record class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -16890,7 +15002,7 @@ public JsonElement Json } } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16899,7 +15011,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16908,7 +15020,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig(JsonElement element) + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -16990,7 +15102,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ); } } @@ -17026,16 +15138,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceMinimumConversionRateConfig( + public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceMinimumConversionRateConfig( + public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -17054,13 +15166,15 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ReplacePricePriceMinimumConversionRateConfig? other) + public virtual bool Equals( + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? other + ) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -17074,10 +15188,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class ReplacePricePriceMinimumConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceMinimumConversionRateConfig? Read( + public override ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17142,14 +15256,16 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceMinimumConversionRateConfig(element); + return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + element + ); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceMinimumConversionRateConfig value, + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { diff --git a/src/Orb/Models/Beta/BetaFetchPlanVersionParams.cs b/src/Orb/Models/Beta/BetaFetchPlanVersionParams.cs index 2ed83f89..640bb60c 100644 --- a/src/Orb/Models/Beta/BetaFetchPlanVersionParams.cs +++ b/src/Orb/Models/Beta/BetaFetchPlanVersionParams.cs @@ -11,8 +11,12 @@ namespace Orb.Models.Beta; /// /// This endpoint is used to fetch a plan version. It returns the phases, prices, /// and adjustments present on this version of the plan. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BetaFetchPlanVersionParams : ParamsBase +public record class BetaFetchPlanVersionParams : ParamsBase { public required string PlanID { get; init; } @@ -20,12 +24,15 @@ public sealed record class BetaFetchPlanVersionParams : ParamsBase public BetaFetchPlanVersionParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BetaFetchPlanVersionParams(BetaFetchPlanVersionParams betaFetchPlanVersionParams) : base(betaFetchPlanVersionParams) { this.PlanID = betaFetchPlanVersionParams.PlanID; this.Version = betaFetchPlanVersionParams.Version; } +#pragma warning restore CS8618 public BetaFetchPlanVersionParams( IReadOnlyDictionary rawHeaderData, @@ -60,6 +67,30 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["PlanID"] = this.PlanID, + ["Version"] = this.Version, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BetaFetchPlanVersionParams? other) + { + if (other == null) + { + return false; + } + return this.PlanID.Equals(other.PlanID) + && (this.Version?.Equals(other.Version) ?? other.Version == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -79,4 +110,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Beta/BetaSetDefaultPlanVersionParams.cs b/src/Orb/Models/Beta/BetaSetDefaultPlanVersionParams.cs index afc5ef44..51329b2a 100644 --- a/src/Orb/Models/Beta/BetaSetDefaultPlanVersionParams.cs +++ b/src/Orb/Models/Beta/BetaSetDefaultPlanVersionParams.cs @@ -11,8 +11,12 @@ namespace Orb.Models.Beta; /// /// This endpoint allows setting the default version of a plan. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BetaSetDefaultPlanVersionParams : ParamsBase +public record class BetaSetDefaultPlanVersionParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -37,6 +41,8 @@ public required long Version public BetaSetDefaultPlanVersionParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BetaSetDefaultPlanVersionParams( BetaSetDefaultPlanVersionParams betaSetDefaultPlanVersionParams ) @@ -46,6 +52,7 @@ BetaSetDefaultPlanVersionParams betaSetDefaultPlanVersionParams this._rawBodyData = new(betaSetDefaultPlanVersionParams._rawBodyData); } +#pragma warning restore CS8618 public BetaSetDefaultPlanVersionParams( IReadOnlyDictionary rawHeaderData, @@ -86,6 +93,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["PlanID"] = this.PlanID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BetaSetDefaultPlanVersionParams? other) + { + if (other == null) + { + return false; + } + return (this.PlanID?.Equals(other.PlanID) ?? other.PlanID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -114,4 +145,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs index 3e4b88ad..e8de0a1a 100644 --- a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs +++ b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs @@ -14,8 +14,12 @@ namespace Orb.Models.Beta.ExternalPlanID; /// /// This endpoint allows the creation of a new plan version for an existing plan. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ExternalPlanIDCreatePlanVersionParams : ParamsBase +public record class ExternalPlanIDCreatePlanVersionParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -41,18 +45,18 @@ public required long Version /// /// Additional adjustments to be added to the plan. /// - public IReadOnlyList? AddAdjustments + public IReadOnlyList? AddAdjustments { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNullableStruct< - ImmutableArray - >("add_adjustments"); + return this._rawBodyData.GetNullableStruct>( + "add_adjustments" + ); } init { - this._rawBodyData.Set?>( + this._rawBodyData.Set?>( "add_adjustments", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -62,18 +66,16 @@ public required long Version /// /// Additional prices to be added to the plan. /// - public IReadOnlyList? AddPrices + public IReadOnlyList? AddPrices { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNullableStruct< - ImmutableArray - >("add_prices"); + return this._rawBodyData.GetNullableStruct>("add_prices"); } init { - this._rawBodyData.Set?>( + this._rawBodyData.Set?>( "add_prices", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -83,18 +85,18 @@ public required long Version /// /// Adjustments to be removed from the plan. /// - public IReadOnlyList? RemoveAdjustments + public IReadOnlyList? RemoveAdjustments { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNullableStruct< - ImmutableArray - >("remove_adjustments"); + return this._rawBodyData.GetNullableStruct>( + "remove_adjustments" + ); } init { - this._rawBodyData.Set?>( + this._rawBodyData.Set?>( "remove_adjustments", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -104,18 +106,18 @@ public required long Version /// /// Prices to be removed from the plan. /// - public IReadOnlyList? RemovePrices + public IReadOnlyList? RemovePrices { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNullableStruct< - ImmutableArray - >("remove_prices"); + return this._rawBodyData.GetNullableStruct>( + "remove_prices" + ); } init { - this._rawBodyData.Set?>( + this._rawBodyData.Set?>( "remove_prices", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -125,18 +127,18 @@ public required long Version /// /// Adjustments to be replaced with additional adjustments on the plan. /// - public IReadOnlyList? ReplaceAdjustments + public IReadOnlyList? ReplaceAdjustments { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNullableStruct< - ImmutableArray - >("replace_adjustments"); + return this._rawBodyData.GetNullableStruct>( + "replace_adjustments" + ); } init { - this._rawBodyData.Set?>( + this._rawBodyData.Set?>( "replace_adjustments", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -146,18 +148,18 @@ public required long Version /// /// Prices to be replaced with additional prices on the plan. /// - public IReadOnlyList? ReplacePrices + public IReadOnlyList? ReplacePrices { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNullableStruct< - ImmutableArray - >("replace_prices"); + return this._rawBodyData.GetNullableStruct>( + "replace_prices" + ); } init { - this._rawBodyData.Set?>( + this._rawBodyData.Set?>( "replace_prices", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -179,6 +181,8 @@ public bool? SetAsDefault public ExternalPlanIDCreatePlanVersionParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ExternalPlanIDCreatePlanVersionParams( ExternalPlanIDCreatePlanVersionParams externalPlanIDCreatePlanVersionParams ) @@ -188,6 +192,7 @@ ExternalPlanIDCreatePlanVersionParams externalPlanIDCreatePlanVersionParams this._rawBodyData = new(externalPlanIDCreatePlanVersionParams._rawBodyData); } +#pragma warning restore CS8618 public ExternalPlanIDCreatePlanVersionParams( IReadOnlyDictionary rawHeaderData, @@ -228,6 +233,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ExternalPlanID"] = this.ExternalPlanID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ExternalPlanIDCreatePlanVersionParams? other) + { + if (other == null) + { + return false; + } + return (this.ExternalPlanID?.Equals(other.ExternalPlanID) ?? other.ExternalPlanID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -256,27 +285,25 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.AddAdjustment, - global::Orb.Models.Beta.ExternalPlanID.AddAdjustmentFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class AddAdjustment : JsonModel { /// /// The definition of a new adjustment to create and add to the plan. /// - public required global::Orb.Models.Beta.ExternalPlanID.Adjustment Adjustment + public required Adjustment Adjustment { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "adjustment" - ); + return this._rawData.GetNotNullClass("adjustment"); } init { this._rawData.Set("adjustment", value); } } @@ -303,7 +330,7 @@ public override void Validate() public AddAdjustment() { } - public AddAdjustment(global::Orb.Models.Beta.ExternalPlanID.AddAdjustment addAdjustment) + public AddAdjustment(AddAdjustment addAdjustment) : base(addAdjustment) { } public AddAdjustment(IReadOnlyDictionary rawData) @@ -319,34 +346,31 @@ public AddAdjustment(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.AddAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static AddAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } [SetsRequiredMembers] - public AddAdjustment(global::Orb.Models.Beta.ExternalPlanID.Adjustment adjustment) + public AddAdjustment(Adjustment adjustment) : this() { this.Adjustment = adjustment; } } -class AddAdjustmentFromRaw : IFromRawJson +class AddAdjustmentFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.AddAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.AddAdjustment.FromRawUnchecked(rawData); + public AddAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => + AddAdjustment.FromRawUnchecked(rawData); } /// /// The definition of a new adjustment to create and add to the plan. /// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.AdjustmentConverter))] +[JsonConverter(typeof(AdjustmentConverter))] public record class Adjustment : ModelBase { public object? Value { get; } = null; @@ -628,25 +652,15 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Adjustment( - NewPercentageDiscount value - ) => new(value); + public static implicit operator Adjustment(NewPercentageDiscount value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Adjustment( - NewUsageDiscount value - ) => new(value); + public static implicit operator Adjustment(NewUsageDiscount value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Adjustment( - NewAmountDiscount value - ) => new(value); + public static implicit operator Adjustment(NewAmountDiscount value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Adjustment( - NewMinimum value - ) => new(value); + public static implicit operator Adjustment(NewMinimum value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Adjustment( - NewMaximum value - ) => new(value); + public static implicit operator Adjustment(NewMaximum value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -673,7 +687,7 @@ public override void Validate() ); } - public virtual bool Equals(global::Orb.Models.Beta.ExternalPlanID.Adjustment? other) + public virtual bool Equals(Adjustment? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -687,9 +701,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class AdjustmentConverter : JsonConverter +sealed class AdjustmentConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.Adjustment? Read( + public override Adjustment? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -814,14 +828,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.Adjustment(element); + return new Adjustment(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.Adjustment value, + Adjustment value, JsonSerializerOptions options ) { @@ -829,12 +843,7 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.AddPrice, - global::Orb.Models.Beta.ExternalPlanID.AddPriceFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class AddPrice : JsonModel { /// @@ -866,14 +875,12 @@ public long? PlanPhaseOrder /// /// New plan price request body params. /// - public global::Orb.Models.Beta.ExternalPlanID.Price? Price + public Price? Price { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "price" - ); + return this._rawData.GetNullableClass("price"); } init { this._rawData.Set("price", value); } } @@ -888,7 +895,7 @@ public override void Validate() public AddPrice() { } - public AddPrice(global::Orb.Models.Beta.ExternalPlanID.AddPrice addPrice) + public AddPrice(AddPrice addPrice) : base(addPrice) { } public AddPrice(IReadOnlyDictionary rawData) @@ -904,27 +911,24 @@ public AddPrice(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.AddPrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static AddPrice FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class AddPriceFromRaw : IFromRawJson +class AddPriceFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.AddPrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.AddPrice.FromRawUnchecked(rawData); + public AddPrice FromRawUnchecked(IReadOnlyDictionary rawData) => + AddPrice.FromRawUnchecked(rawData); } /// /// New plan price request body params. /// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.PriceConverter))] +[JsonConverter(typeof(PriceConverter))] public record class Price : ModelBase { public object? Value { get; } = null; @@ -975,7 +979,6 @@ public string ItemID newPlanScalableMatrixWithTieredPricing: (x) => x.ItemID, newPlanCumulativeGroupedBulk: (x) => x.ItemID, cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, newPlanMinimumComposite: (x) => x.ItemID, percent: (x) => x.ItemID, eventOutput: (x) => x.ItemID @@ -1016,7 +1019,6 @@ public string Name newPlanScalableMatrixWithTieredPricing: (x) => x.Name, newPlanCumulativeGroupedBulk: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, newPlanMinimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name @@ -1057,7 +1059,6 @@ public string? BillableMetricID newPlanScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, newPlanCumulativeGroupedBulk: (x) => x.BillableMetricID, cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, newPlanMinimumComposite: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID @@ -1098,7 +1099,6 @@ public bool? BilledInAdvance newPlanScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, newPlanCumulativeGroupedBulk: (x) => x.BilledInAdvance, cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, newPlanMinimumComposite: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance @@ -1139,7 +1139,6 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newPlanScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, newPlanCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, newPlanMinimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration @@ -1180,7 +1179,6 @@ public double? ConversionRate newPlanScalableMatrixWithTieredPricing: (x) => x.ConversionRate, newPlanCumulativeGroupedBulk: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, newPlanMinimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate @@ -1221,7 +1219,6 @@ public string? Currency newPlanScalableMatrixWithTieredPricing: (x) => x.Currency, newPlanCumulativeGroupedBulk: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, newPlanMinimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency @@ -1262,7 +1259,6 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration newPlanScalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, newPlanCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, newPlanMinimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration @@ -1303,7 +1299,6 @@ public string? ExternalPriceID newPlanScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, newPlanCumulativeGroupedBulk: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, newPlanMinimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID @@ -1344,7 +1339,6 @@ public double? FixedPriceQuantity newPlanScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, newPlanCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, newPlanMinimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity @@ -1385,7 +1379,6 @@ public string? InvoiceGroupingKey newPlanScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, newPlanCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, newPlanMinimumComposite: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey @@ -1426,7 +1419,6 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration newPlanScalableMatrixWithTieredPricing: (x) => x.InvoicingCycleConfiguration, newPlanCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, newPlanMinimumComposite: (x) => x.InvoicingCycleConfiguration, percent: (x) => x.InvoicingCycleConfiguration, eventOutput: (x) => x.InvoicingCycleConfiguration @@ -1467,7 +1459,6 @@ public string? ReferenceID newPlanScalableMatrixWithTieredPricing: (x) => x.ReferenceID, newPlanCumulativeGroupedBulk: (x) => x.ReferenceID, cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, newPlanMinimumComposite: (x) => x.ReferenceID, percent: (x) => x.ReferenceID, eventOutput: (x) => x.ReferenceID @@ -1493,10 +1484,7 @@ public Price(NewPlanBulkPrice value, JsonElement? element = null) this._element = element; } - public Price( - global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters value, - JsonElement? element = null - ) + public Price(BulkWithFilters value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1562,10 +1550,7 @@ public Price(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null this._element = element; } - public Price( - global::Orb.Models.Beta.ExternalPlanID.TieredWithProration value, - JsonElement? element = null - ) + public Price(TieredWithProration value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1601,10 +1586,7 @@ public Price(NewPlanGroupedWithMeteredMinimumPrice value, JsonElement? element = this._element = element; } - public Price( - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds value, - JsonElement? element = null - ) + public Price(GroupedWithMinMaxThresholds value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1646,16 +1628,7 @@ public Price(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = nul this._element = element; } - public Price( - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public Price(global::Orb.Models.Beta.ExternalPlanID.Minimum value, JsonElement? element = null) + public Price(CumulativeGroupedAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1667,16 +1640,13 @@ public Price(NewPlanMinimumCompositePrice value, JsonElement? element = null) this._element = element; } - public Price(global::Orb.Models.Beta.ExternalPlanID.Percent value, JsonElement? element = null) + public Price(Percent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price( - global::Orb.Models.Beta.ExternalPlanID.EventOutput value, - JsonElement? element = null - ) + public Price(EventOutput value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1752,24 +1722,22 @@ public bool TryPickNewPlanBulk([NotNullWhen(true)] out NewPlanBulkPrice? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickBulkWithFilters(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters` + /// // `value` is of type `BulkWithFilters` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickBulkWithFilters( - [NotNullWhen(true)] out global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters? value - ) + public bool TryPickBulkWithFilters([NotNullWhen(true)] out BulkWithFilters? value) { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters; + value = this.Value as BulkWithFilters; return value != null; } @@ -2001,24 +1969,22 @@ public bool TryPickNewPlanMatrixWithAllocation( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickTieredWithProration(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.TieredWithProration` + /// // `value` is of type `TieredWithProration` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTieredWithProration( - [NotNullWhen(true)] out global::Orb.Models.Beta.ExternalPlanID.TieredWithProration? value - ) + public bool TryPickTieredWithProration([NotNullWhen(true)] out TieredWithProration? value) { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.TieredWithProration; + value = this.Value as TieredWithProration; return value != null; } @@ -2139,25 +2105,24 @@ public bool TryPickNewPlanGroupedWithMeteredMinimum( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickGroupedWithMinMaxThresholds(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds` + /// // `value` is of type `GroupedWithMinMaxThresholds` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds? value + [NotNullWhen(true)] out GroupedWithMinMaxThresholds? value ) { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds; + value = this.Value as GroupedWithMinMaxThresholds; return value != null; } @@ -2301,48 +2266,24 @@ public bool TryPickNewPlanCumulativeGroupedBulk( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation` + /// // `value` is of type `CumulativeGroupedAllocation` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation? value + [NotNullWhen(true)] out CumulativeGroupedAllocation? value ) { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.Minimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum( - [NotNullWhen(true)] out global::Orb.Models.Beta.ExternalPlanID.Minimum? value - ) - { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.Minimum; + value = this.Value as CumulativeGroupedAllocation; return value != null; } @@ -2371,47 +2312,43 @@ public bool TryPickNewPlanMinimumComposite( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickPercent(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.Percent` + /// // `value` is of type `Percent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickPercent( - [NotNullWhen(true)] out global::Orb.Models.Beta.ExternalPlanID.Percent? value - ) + public bool TryPickPercent([NotNullWhen(true)] out Percent? value) { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.Percent; + value = this.Value as Percent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickEventOutput(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.EventOutput` + /// // `value` is of type `EventOutput` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickEventOutput( - [NotNullWhen(true)] out global::Orb.Models.Beta.ExternalPlanID.EventOutput? value - ) + public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.EventOutput; + value = this.Value as EventOutput; return value != null; } @@ -2432,7 +2369,7 @@ public bool TryPickEventOutput( /// (NewPlanUnitPrice value) => {...}, /// (NewPlanTieredPrice value) => {...}, /// (NewPlanBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters value) => {...}, + /// (BulkWithFilters value) => {...}, /// (NewPlanPackagePrice value) => {...}, /// (NewPlanMatrixPrice value) => {...}, /// (NewPlanThresholdTotalAmountPrice value) => {...}, @@ -2443,24 +2380,23 @@ public bool TryPickEventOutput( /// (NewPlanPackageWithAllocationPrice value) => {...}, /// (NewPlanUnitWithPercentPrice value) => {...}, /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.TieredWithProration value) => {...}, + /// (TieredWithProration value) => {...}, /// (NewPlanUnitWithProrationPrice value) => {...}, /// (NewPlanGroupedAllocationPrice value) => {...}, /// (NewPlanBulkWithProrationPrice value) => {...}, /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, /// (NewPlanGroupedTieredPackagePrice value) => {...}, /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.Minimum value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.Percent value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.EventOutput value) => {...} + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -2469,7 +2405,7 @@ public void Switch( System::Action newPlanUnit, System::Action newPlanTiered, System::Action newPlanBulk, - System::Action bulkWithFilters, + System::Action bulkWithFilters, System::Action newPlanPackage, System::Action newPlanMatrix, System::Action newPlanThresholdTotalAmount, @@ -2480,24 +2416,23 @@ public void Switch( System::Action newPlanPackageWithAllocation, System::Action newPlanUnitWithPercent, System::Action newPlanMatrixWithAllocation, - System::Action tieredWithProration, + System::Action tieredWithProration, System::Action newPlanUnitWithProration, System::Action newPlanGroupedAllocation, System::Action newPlanBulkWithProration, System::Action newPlanGroupedWithProratedMinimum, System::Action newPlanGroupedWithMeteredMinimum, - System::Action groupedWithMinMaxThresholds, + System::Action groupedWithMinMaxThresholds, System::Action newPlanMatrixWithDisplayName, System::Action newPlanGroupedTieredPackage, System::Action newPlanMaxGroupTieredPackage, System::Action newPlanScalableMatrixWithUnitPricing, System::Action newPlanScalableMatrixWithTieredPricing, System::Action newPlanCumulativeGroupedBulk, - System::Action cumulativeGroupedAllocation, - System::Action minimum, + System::Action cumulativeGroupedAllocation, System::Action newPlanMinimumComposite, - System::Action percent, - System::Action eventOutput + System::Action percent, + System::Action eventOutput ) { switch (this.Value) @@ -2511,7 +2446,7 @@ public void Switch( case NewPlanBulkPrice value: newPlanBulk(value); break; - case global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters value: + case BulkWithFilters value: bulkWithFilters(value); break; case NewPlanPackagePrice value: @@ -2544,7 +2479,7 @@ public void Switch( case NewPlanMatrixWithAllocationPrice value: newPlanMatrixWithAllocation(value); break; - case global::Orb.Models.Beta.ExternalPlanID.TieredWithProration value: + case TieredWithProration value: tieredWithProration(value); break; case NewPlanUnitWithProrationPrice value: @@ -2562,7 +2497,7 @@ public void Switch( case NewPlanGroupedWithMeteredMinimumPrice value: newPlanGroupedWithMeteredMinimum(value); break; - case global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds value: + case GroupedWithMinMaxThresholds value: groupedWithMinMaxThresholds(value); break; case NewPlanMatrixWithDisplayNamePrice value: @@ -2583,19 +2518,16 @@ public void Switch( case NewPlanCumulativeGroupedBulkPrice value: newPlanCumulativeGroupedBulk(value); break; - case global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation value: + case CumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case global::Orb.Models.Beta.ExternalPlanID.Minimum value: - minimum(value); - break; case NewPlanMinimumCompositePrice value: newPlanMinimumComposite(value); break; - case global::Orb.Models.Beta.ExternalPlanID.Percent value: + case Percent value: percent(value); break; - case global::Orb.Models.Beta.ExternalPlanID.EventOutput value: + case EventOutput value: eventOutput(value); break; default: @@ -2621,7 +2553,7 @@ public void Switch( /// (NewPlanUnitPrice value) => {...}, /// (NewPlanTieredPrice value) => {...}, /// (NewPlanBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters value) => {...}, + /// (BulkWithFilters value) => {...}, /// (NewPlanPackagePrice value) => {...}, /// (NewPlanMatrixPrice value) => {...}, /// (NewPlanThresholdTotalAmountPrice value) => {...}, @@ -2632,24 +2564,23 @@ public void Switch( /// (NewPlanPackageWithAllocationPrice value) => {...}, /// (NewPlanUnitWithPercentPrice value) => {...}, /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.TieredWithProration value) => {...}, + /// (TieredWithProration value) => {...}, /// (NewPlanUnitWithProrationPrice value) => {...}, /// (NewPlanGroupedAllocationPrice value) => {...}, /// (NewPlanBulkWithProrationPrice value) => {...}, /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, /// (NewPlanGroupedTieredPackagePrice value) => {...}, /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.Minimum value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.Percent value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.EventOutput value) => {...} + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -2658,7 +2589,7 @@ public T Match( System::Func newPlanUnit, System::Func newPlanTiered, System::Func newPlanBulk, - System::Func bulkWithFilters, + System::Func bulkWithFilters, System::Func newPlanPackage, System::Func newPlanMatrix, System::Func newPlanThresholdTotalAmount, @@ -2669,19 +2600,13 @@ public T Match( System::Func newPlanPackageWithAllocation, System::Func newPlanUnitWithPercent, System::Func newPlanMatrixWithAllocation, - System::Func< - global::Orb.Models.Beta.ExternalPlanID.TieredWithProration, - T - > tieredWithProration, + System::Func tieredWithProration, System::Func newPlanUnitWithProration, System::Func newPlanGroupedAllocation, System::Func newPlanBulkWithProration, System::Func newPlanGroupedWithProratedMinimum, System::Func newPlanGroupedWithMeteredMinimum, - System::Func< - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds, - T - > groupedWithMinMaxThresholds, + System::Func groupedWithMinMaxThresholds, System::Func newPlanMatrixWithDisplayName, System::Func newPlanGroupedTieredPackage, System::Func newPlanMaxGroupTieredPackage, @@ -2694,14 +2619,10 @@ public T Match( T > newPlanScalableMatrixWithTieredPricing, System::Func newPlanCumulativeGroupedBulk, - System::Func< - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation, - T - > cumulativeGroupedAllocation, - System::Func minimum, + System::Func cumulativeGroupedAllocation, System::Func newPlanMinimumComposite, - System::Func percent, - System::Func eventOutput + System::Func percent, + System::Func eventOutput ) { return this.Value switch @@ -2709,7 +2630,7 @@ public T Match( NewPlanUnitPrice value => newPlanUnit(value), NewPlanTieredPrice value => newPlanTiered(value), NewPlanBulkPrice value => newPlanBulk(value), - global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters value => bulkWithFilters(value), + BulkWithFilters value => bulkWithFilters(value), NewPlanPackagePrice value => newPlanPackage(value), NewPlanMatrixPrice value => newPlanMatrix(value), NewPlanThresholdTotalAmountPrice value => newPlanThresholdTotalAmount(value), @@ -2720,9 +2641,7 @@ public T Match( NewPlanPackageWithAllocationPrice value => newPlanPackageWithAllocation(value), NewPlanUnitWithPercentPrice value => newPlanUnitWithPercent(value), NewPlanMatrixWithAllocationPrice value => newPlanMatrixWithAllocation(value), - global::Orb.Models.Beta.ExternalPlanID.TieredWithProration value => tieredWithProration( - value - ), + TieredWithProration value => tieredWithProration(value), NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), @@ -2730,8 +2649,7 @@ public T Match( value ), NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds value => - groupedWithMinMaxThresholds(value), + GroupedWithMinMaxThresholds value => groupedWithMinMaxThresholds(value), NewPlanMatrixWithDisplayNamePrice value => newPlanMatrixWithDisplayName(value), NewPlanGroupedTieredPackagePrice value => newPlanGroupedTieredPackage(value), NewPlanMaxGroupTieredPackagePrice value => newPlanMaxGroupTieredPackage(value), @@ -2741,143 +2659,79 @@ public T Match( NewPlanScalableMatrixWithTieredPricingPrice value => newPlanScalableMatrixWithTieredPricing(value), NewPlanCumulativeGroupedBulkPrice value => newPlanCumulativeGroupedBulk(value), - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation value => - cumulativeGroupedAllocation(value), - global::Orb.Models.Beta.ExternalPlanID.Minimum value => minimum(value), + CumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), - global::Orb.Models.Beta.ExternalPlanID.Percent value => percent(value), - global::Orb.Models.Beta.ExternalPlanID.EventOutput value => eventOutput(value), + Percent value => percent(value), + EventOutput value => eventOutput(value), _ => throw new OrbInvalidDataException("Data did not match any variant of Price"), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanUnitPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanTieredPrice value - ) => new(value); + public static implicit operator Price(NewPlanUnitPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanBulkPrice value - ) => new(value); + public static implicit operator Price(NewPlanTieredPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters value - ) => new(value); + public static implicit operator Price(NewPlanBulkPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanPackagePrice value - ) => new(value); + public static implicit operator Price(BulkWithFilters value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanMatrixPrice value - ) => new(value); + public static implicit operator Price(NewPlanPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanThresholdTotalAmountPrice value - ) => new(value); + public static implicit operator Price(NewPlanMatrixPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewPlanThresholdTotalAmountPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanTieredWithMinimumPrice value - ) => new(value); + public static implicit operator Price(NewPlanTieredPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanGroupedTieredPrice value - ) => new(value); + public static implicit operator Price(NewPlanTieredWithMinimumPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanTieredPackageWithMinimumPrice value - ) => new(value); + public static implicit operator Price(NewPlanGroupedTieredPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanPackageWithAllocationPrice value - ) => new(value); + public static implicit operator Price(NewPlanTieredPackageWithMinimumPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanUnitWithPercentPrice value - ) => new(value); + public static implicit operator Price(NewPlanPackageWithAllocationPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanMatrixWithAllocationPrice value - ) => new(value); + public static implicit operator Price(NewPlanUnitWithPercentPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - global::Orb.Models.Beta.ExternalPlanID.TieredWithProration value - ) => new(value); + public static implicit operator Price(NewPlanMatrixWithAllocationPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanUnitWithProrationPrice value - ) => new(value); + public static implicit operator Price(TieredWithProration value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanGroupedAllocationPrice value - ) => new(value); + public static implicit operator Price(NewPlanUnitWithProrationPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanBulkWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewPlanGroupedAllocationPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanGroupedWithProratedMinimumPrice value - ) => new(value); + public static implicit operator Price(NewPlanBulkWithProrationPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanGroupedWithMeteredMinimumPrice value - ) => new(value); + public static implicit operator Price(NewPlanGroupedWithProratedMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds value - ) => new(value); + public static implicit operator Price(NewPlanGroupedWithMeteredMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanMatrixWithDisplayNamePrice value - ) => new(value); + public static implicit operator Price(GroupedWithMinMaxThresholds value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanGroupedTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewPlanMatrixWithDisplayNamePrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanMaxGroupTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewPlanGroupedTieredPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanScalableMatrixWithUnitPricingPrice value - ) => new(value); + public static implicit operator Price(NewPlanMaxGroupTieredPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanScalableMatrixWithTieredPricingPrice value - ) => new(value); + public static implicit operator Price(NewPlanScalableMatrixWithUnitPricingPrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanCumulativeGroupedBulkPrice value - ) => new(value); + public static implicit operator Price(NewPlanScalableMatrixWithTieredPricingPrice value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation value - ) => new(value); + public static implicit operator Price(NewPlanCumulativeGroupedBulkPrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - global::Orb.Models.Beta.ExternalPlanID.Minimum value - ) => new(value); + public static implicit operator Price(CumulativeGroupedAllocation value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanMinimumCompositePrice value - ) => new(value); + public static implicit operator Price(NewPlanMinimumCompositePrice value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - global::Orb.Models.Beta.ExternalPlanID.Percent value - ) => new(value); + public static implicit operator Price(Percent value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - global::Orb.Models.Beta.ExternalPlanID.EventOutput value - ) => new(value); + public static implicit operator Price(EventOutput value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2926,14 +2780,13 @@ public override void Validate() newPlanScalableMatrixWithTieredPricing.Validate(), (newPlanCumulativeGroupedBulk) => newPlanCumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), (newPlanMinimumComposite) => newPlanMinimumComposite.Validate(), (percent) => percent.Validate(), (eventOutput) => eventOutput.Validate() ); } - public virtual bool Equals(global::Orb.Models.Beta.ExternalPlanID.Price? other) + public virtual bool Equals(Price? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -2947,9 +2800,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class PriceConverter : JsonConverter +sealed class PriceConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.Price? Read( + public override Price? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -3038,11 +2891,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3283,11 +3135,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3418,11 +3269,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3578,34 +3428,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3646,11 +3472,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3669,11 +3491,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3690,40 +3508,29 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.Price(element); + return new Price(element); } } } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.Price? value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Price? value, JsonSerializerOptions options) { JsonSerializer.Serialize(writer, value?.Json, options); } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters, - global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class BulkWithFilters : JsonModel { /// /// Configuration for bulk_with_filters pricing /// - public required global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfig BulkWithFiltersConfig + public required BulkWithFiltersConfig BulkWithFiltersConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "bulk_with_filters_config" - ); + return this._rawData.GetNotNullClass("bulk_with_filters_config"); } init { this._rawData.Set("bulk_with_filters_config", value); } } @@ -3731,14 +3538,12 @@ public sealed record class BulkWithFilters : JsonModel /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } @@ -3841,14 +3646,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfig? ConversionRateConfig + public ConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); + return this._rawData.GetNullableClass("conversion_rate_config"); } init { this._rawData.Set("conversion_rate_config", value); } } @@ -4008,7 +3811,7 @@ public BulkWithFilters() this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } - public BulkWithFilters(global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters bulkWithFilters) + public BulkWithFilters(BulkWithFilters bulkWithFilters) : base(bulkWithFilters) { } public BulkWithFilters(IReadOnlyDictionary rawData) @@ -4026,49 +3829,39 @@ public BulkWithFilters(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class BulkWithFiltersFromRaw : IFromRawJson +class BulkWithFiltersFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters.FromRawUnchecked(rawData); + public BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) => + BulkWithFilters.FromRawUnchecked(rawData); } /// /// Configuration for bulk_with_filters pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfig, - global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class BulkWithFiltersConfig : JsonModel { /// /// Property filters to apply (all must match) /// - public required IReadOnlyList Filters + public required IReadOnlyList Filters { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("filters"); + return this._rawData.GetNotNullStruct>("filters"); } init { - this._rawData.Set>( + this._rawData.Set>( "filters", ImmutableArray.ToImmutableArray(value) ); @@ -4078,18 +3871,16 @@ public sealed record class BulkWithFiltersConfig : JsonModel /// /// Bulk tiers for rating based on total usage volume /// - public required IReadOnlyList Tiers + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + return this._rawData.GetNotNullStruct>("tiers"); } init { - this._rawData.Set>( + this._rawData.Set>( "tiers", ImmutableArray.ToImmutableArray(value) ); @@ -4111,9 +3902,7 @@ public override void Validate() public BulkWithFiltersConfig() { } - public BulkWithFiltersConfig( - global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfig bulkWithFiltersConfig - ) + public BulkWithFiltersConfig(BulkWithFiltersConfig bulkWithFiltersConfig) : base(bulkWithFiltersConfig) { } public BulkWithFiltersConfig(IReadOnlyDictionary rawData) @@ -4129,8 +3918,8 @@ public BulkWithFiltersConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfig FromRawUnchecked( + /// + public static BulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4138,24 +3927,18 @@ IReadOnlyDictionary rawData } } -class BulkWithFiltersConfigFromRaw - : IFromRawJson +class BulkWithFiltersConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfig FromRawUnchecked( + public BulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfig.FromRawUnchecked(rawData); + ) => BulkWithFiltersConfig.FromRawUnchecked(rawData); } /// /// Configuration for a single property filter /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.Filter, - global::Orb.Models.Beta.ExternalPlanID.FilterFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Filter : JsonModel { /// @@ -4193,7 +3976,7 @@ public override void Validate() public Filter() { } - public Filter(global::Orb.Models.Beta.ExternalPlanID.Filter filter) + public Filter(Filter filter) : base(filter) { } public Filter(IReadOnlyDictionary rawData) @@ -4209,32 +3992,24 @@ public Filter(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Filter FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class FilterFromRaw : IFromRawJson +class FilterFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.Filter.FromRawUnchecked(rawData); + public Filter FromRawUnchecked(IReadOnlyDictionary rawData) => + Filter.FromRawUnchecked(rawData); } /// /// Configuration for a single bulk pricing tier /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.Tier, - global::Orb.Models.Beta.ExternalPlanID.TierFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Tier : JsonModel { /// @@ -4272,7 +4047,7 @@ public override void Validate() public Tier() { } - public Tier(global::Orb.Models.Beta.ExternalPlanID.Tier tier) + public Tier(Tier tier) : base(tier) { } public Tier(IReadOnlyDictionary rawData) @@ -4288,10 +4063,8 @@ public Tier(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Tier FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } @@ -4304,18 +4077,17 @@ public Tier(string unitAmount) } } -class TierFromRaw : IFromRawJson +class TierFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.Tier.FromRawUnchecked(rawData); + public Tier FromRawUnchecked(IReadOnlyDictionary rawData) => + Tier.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.CadenceConverter))] +[JsonConverter(typeof(CadenceConverter))] public enum Cadence { Annual, @@ -4326,9 +4098,9 @@ public enum Cadence Custom, } -sealed class CadenceConverter : JsonConverter +sealed class CadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.Cadence Read( + public override Cadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4336,32 +4108,28 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Beta.ExternalPlanID.Cadence.Annual, - "semi_annual" => global::Orb.Models.Beta.ExternalPlanID.Cadence.SemiAnnual, - "monthly" => global::Orb.Models.Beta.ExternalPlanID.Cadence.Monthly, - "quarterly" => global::Orb.Models.Beta.ExternalPlanID.Cadence.Quarterly, - "one_time" => global::Orb.Models.Beta.ExternalPlanID.Cadence.OneTime, - "custom" => global::Orb.Models.Beta.ExternalPlanID.Cadence.Custom, - _ => (global::Orb.Models.Beta.ExternalPlanID.Cadence)(-1), + "annual" => Cadence.Annual, + "semi_annual" => Cadence.SemiAnnual, + "monthly" => Cadence.Monthly, + "quarterly" => Cadence.Quarterly, + "one_time" => Cadence.OneTime, + "custom" => Cadence.Custom, + _ => (Cadence)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.Cadence value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Cadence value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Beta.ExternalPlanID.Cadence.Annual => "annual", - global::Orb.Models.Beta.ExternalPlanID.Cadence.SemiAnnual => "semi_annual", - global::Orb.Models.Beta.ExternalPlanID.Cadence.Monthly => "monthly", - global::Orb.Models.Beta.ExternalPlanID.Cadence.Quarterly => "quarterly", - global::Orb.Models.Beta.ExternalPlanID.Cadence.OneTime => "one_time", - global::Orb.Models.Beta.ExternalPlanID.Cadence.Custom => "custom", + Cadence.Annual => "annual", + Cadence.SemiAnnual => "semi_annual", + Cadence.Monthly => "monthly", + Cadence.Quarterly => "quarterly", + Cadence.OneTime => "one_time", + Cadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -4371,7 +4139,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfigConverter))] +[JsonConverter(typeof(ConversionRateConfigConverter))] public record class ConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -4524,13 +4292,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); + public static implicit operator ConversionRateConfig(SharedUnitConversionRateConfig value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); + public static implicit operator ConversionRateConfig(SharedTieredConversionRateConfig value) => + new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -4553,7 +4319,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfig? other) + public virtual bool Equals(ConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -4567,10 +4333,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class ConversionRateConfigConverter - : JsonConverter +sealed class ConversionRateConfigConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfig? Read( + public override ConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4635,14 +4400,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfig(element); + return new ConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfig value, + ConversionRateConfig value, JsonSerializerOptions options ) { @@ -4650,28 +4415,20 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.TieredWithProration, - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class TieredWithProration : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } init { this._rawData.Set("cadence", value); } } @@ -4718,12 +4475,12 @@ public required string Name /// /// Configuration for tiered_with_proration pricing /// - public required global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfig TieredWithProrationConfig + public required TieredWithProrationConfig TieredWithProrationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "tiered_with_proration_config" ); } @@ -4789,12 +4546,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfig? ConversionRateConfig + public TieredWithProrationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -4956,9 +4713,7 @@ public TieredWithProration() this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } - public TieredWithProration( - global::Orb.Models.Beta.ExternalPlanID.TieredWithProration tieredWithProration - ) + public TieredWithProration(TieredWithProration tieredWithProration) : base(tieredWithProration) { } public TieredWithProration(IReadOnlyDictionary rawData) @@ -4976,8 +4731,8 @@ public TieredWithProration(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.TieredWithProration FromRawUnchecked( + /// + public static TieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4985,19 +4740,17 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationFromRaw - : IFromRawJson +class TieredWithProrationFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.TieredWithProration FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.TieredWithProration.FromRawUnchecked(rawData); + public TieredWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredWithProration.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadenceConverter))] +[JsonConverter(typeof(TieredWithProrationCadenceConverter))] public enum TieredWithProrationCadence { Annual, @@ -5008,10 +4761,9 @@ public enum TieredWithProrationCadence Custom, } -sealed class TieredWithProrationCadenceConverter - : JsonConverter +sealed class TieredWithProrationCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence Read( + public override TieredWithProrationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5019,29 +4771,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence.Annual, - "semi_annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .TieredWithProrationCadence - .SemiAnnual, - "monthly" => global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence.Monthly, - "quarterly" => global::Orb - .Models - .Beta - .ExternalPlanID - .TieredWithProrationCadence - .Quarterly, - "one_time" => global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence.OneTime, - "custom" => global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence.Custom, - _ => (global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence)(-1), + "annual" => TieredWithProrationCadence.Annual, + "semi_annual" => TieredWithProrationCadence.SemiAnnual, + "monthly" => TieredWithProrationCadence.Monthly, + "quarterly" => TieredWithProrationCadence.Quarterly, + "one_time" => TieredWithProrationCadence.OneTime, + "custom" => TieredWithProrationCadence.Custom, + _ => (TieredWithProrationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence value, + TieredWithProrationCadence value, JsonSerializerOptions options ) { @@ -5049,18 +4791,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence.Annual => - "annual", - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence.SemiAnnual => - "semi_annual", - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence.Monthly => - "monthly", - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence.Quarterly => - "quarterly", - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence.OneTime => - "one_time", - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence.Custom => - "custom", + TieredWithProrationCadence.Annual => "annual", + TieredWithProrationCadence.SemiAnnual => "semi_annual", + TieredWithProrationCadence.Monthly => "monthly", + TieredWithProrationCadence.Quarterly => "quarterly", + TieredWithProrationCadence.OneTime => "one_time", + TieredWithProrationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -5074,10 +4810,7 @@ JsonSerializerOptions options /// Configuration for tiered_with_proration pricing /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfig, - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfigFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class TieredWithProrationConfig : JsonModel { @@ -5085,20 +4818,21 @@ public sealed record class TieredWithProrationConfig : JsonModel /// Tiers for rating based on total usage quantities into the specified tier /// with proration /// - public required IReadOnlyList Tiers + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + return this._rawData.GetNotNullStruct>( + "tiers" + ); } init { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); } } @@ -5113,9 +4847,7 @@ public override void Validate() public TieredWithProrationConfig() { } - public TieredWithProrationConfig( - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfig tieredWithProrationConfig - ) + public TieredWithProrationConfig(TieredWithProrationConfig tieredWithProrationConfig) : base(tieredWithProrationConfig) { } public TieredWithProrationConfig(IReadOnlyDictionary rawData) @@ -5131,8 +4863,8 @@ public TieredWithProrationConfig(IReadOnlyDictionary rawDat } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfig FromRawUnchecked( + /// + public static TieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5140,32 +4872,26 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public TieredWithProrationConfig( - IReadOnlyList tiers - ) + public TieredWithProrationConfig(IReadOnlyList tiers) : this() { this.Tiers = tiers; } } -class TieredWithProrationConfigFromRaw - : IFromRawJson +class TieredWithProrationConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfig FromRawUnchecked( + public TieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfig.FromRawUnchecked(rawData); + ) => TieredWithProrationConfig.FromRawUnchecked(rawData); } /// /// Configuration for a single tiered with proration tier /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfigTier, - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfigTierFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class TieredWithProrationConfigTier : JsonModel { @@ -5205,7 +4931,7 @@ public override void Validate() public TieredWithProrationConfigTier() { } public TieredWithProrationConfigTier( - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfigTier tieredWithProrationConfigTier + TieredWithProrationConfigTier tieredWithProrationConfigTier ) : base(tieredWithProrationConfigTier) { } @@ -5222,8 +4948,8 @@ public TieredWithProrationConfigTier(IReadOnlyDictionary ra } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfigTier FromRawUnchecked( + /// + public static TieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5231,21 +4957,15 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationConfigTierFromRaw - : IFromRawJson +class TieredWithProrationConfigTierFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfigTier FromRawUnchecked( + public TieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfigTier.FromRawUnchecked( - rawData - ); + ) => TieredWithProrationConfigTier.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfigConverter) -)] +[JsonConverter(typeof(TieredWithProrationConversionRateConfigConverter))] public record class TieredWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5404,11 +5124,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfig( + public static implicit operator TieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfig( + public static implicit operator TieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -5433,9 +5153,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfig? other - ) + public virtual bool Equals(TieredWithProrationConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -5450,9 +5168,9 @@ public override string ToString() => } sealed class TieredWithProrationConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfig? Read( + public override TieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5517,16 +5235,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfig( - element - ); + return new TieredWithProrationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfig value, + TieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -5535,29 +5251,20 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds, - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class GroupedWithMinMaxThresholds : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsCadence - > + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -5566,12 +5273,12 @@ public required ApiEnum< /// /// Configuration for grouped_with_min_max_thresholds pricing /// - public required global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + public required GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "grouped_with_min_max_thresholds_config" ); } @@ -5676,12 +5383,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + public GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5843,9 +5550,7 @@ public GroupedWithMinMaxThresholds() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } - public GroupedWithMinMaxThresholds( - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds groupedWithMinMaxThresholds - ) + public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) : base(groupedWithMinMaxThresholds) { } public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) @@ -5863,8 +5568,8 @@ public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawD } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5872,24 +5577,18 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class GroupedWithMinMaxThresholdsFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds FromRawUnchecked( + public GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds.FromRawUnchecked( - rawData - ); + ) => GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsCadenceConverter) -)] +[JsonConverter(typeof(GroupedWithMinMaxThresholdsCadenceConverter))] public enum GroupedWithMinMaxThresholdsCadence { Annual, @@ -5901,9 +5600,9 @@ public enum GroupedWithMinMaxThresholdsCadence } sealed class GroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsCadence Read( + public override GroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5911,49 +5610,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .GroupedWithMinMaxThresholdsCadence - .Annual, - "semi_annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .GroupedWithMinMaxThresholdsCadence - .SemiAnnual, - "monthly" => global::Orb - .Models - .Beta - .ExternalPlanID - .GroupedWithMinMaxThresholdsCadence - .Monthly, - "quarterly" => global::Orb - .Models - .Beta - .ExternalPlanID - .GroupedWithMinMaxThresholdsCadence - .Quarterly, - "one_time" => global::Orb - .Models - .Beta - .ExternalPlanID - .GroupedWithMinMaxThresholdsCadence - .OneTime, - "custom" => global::Orb - .Models - .Beta - .ExternalPlanID - .GroupedWithMinMaxThresholdsCadence - .Custom, - _ => (global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsCadence)(-1), + "annual" => GroupedWithMinMaxThresholdsCadence.Annual, + "semi_annual" => GroupedWithMinMaxThresholdsCadence.SemiAnnual, + "monthly" => GroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => GroupedWithMinMaxThresholdsCadence.Quarterly, + "one_time" => GroupedWithMinMaxThresholdsCadence.OneTime, + "custom" => GroupedWithMinMaxThresholdsCadence.Custom, + _ => (GroupedWithMinMaxThresholdsCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsCadence value, + GroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -5961,26 +5630,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsCadence.Annual => - "annual", - global::Orb - .Models - .Beta - .ExternalPlanID - .GroupedWithMinMaxThresholdsCadence - .SemiAnnual => "semi_annual", - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsCadence.Monthly => - "monthly", - global::Orb - .Models - .Beta - .ExternalPlanID - .GroupedWithMinMaxThresholdsCadence - .Quarterly => "quarterly", - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsCadence.OneTime => - "one_time", - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsCadence.Custom => - "custom", + GroupedWithMinMaxThresholdsCadence.Annual => "annual", + GroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", + GroupedWithMinMaxThresholdsCadence.Monthly => "monthly", + GroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", + GroupedWithMinMaxThresholdsCadence.OneTime => "one_time", + GroupedWithMinMaxThresholdsCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -5995,8 +5650,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfig, - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfigFromRaw + GroupedWithMinMaxThresholdsConfig, + GroupedWithMinMaxThresholdsConfigFromRaw >) )] public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel @@ -6065,7 +5720,7 @@ public override void Validate() public GroupedWithMinMaxThresholdsConfig() { } public GroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig + GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) : base(groupedWithMinMaxThresholdsConfig) { } @@ -6082,8 +5737,8 @@ public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary - public static global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6091,21 +5746,15 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class GroupedWithMinMaxThresholdsConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfig.FromRawUnchecked( - rawData - ); + ) => GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfigConverter) -)] +[JsonConverter(typeof(GroupedWithMinMaxThresholdsConversionRateConfigConverter))] public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6264,11 +5913,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6293,9 +5942,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfig? other - ) + public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -6310,9 +5957,9 @@ public override string ToString() => } sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override GroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6377,16 +6024,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfig( - element - ); + return new GroupedWithMinMaxThresholdsConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfig value, + GroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -6395,29 +6040,20 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation, - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class CumulativeGroupedAllocation : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadence - > + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -6426,12 +6062,12 @@ public required ApiEnum< /// /// Configuration for cumulative_grouped_allocation pricing /// - public required global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "cumulative_grouped_allocation_config" ); } @@ -6536,12 +6172,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + public CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -6703,9 +6339,7 @@ public CumulativeGroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public CumulativeGroupedAllocation( - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation cumulativeGroupedAllocation - ) + public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) : base(cumulativeGroupedAllocation) { } public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) @@ -6723,8 +6357,8 @@ public CumulativeGroupedAllocation(IReadOnlyDictionary rawD } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation FromRawUnchecked( + /// + public static CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6732,24 +6366,18 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationFromRaw - : IFromRawJson +class CumulativeGroupedAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation FromRawUnchecked( + public CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation.FromRawUnchecked( - rawData - ); + ) => CumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadenceConverter) -)] +[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] public enum CumulativeGroupedAllocationCadence { Annual, @@ -6761,9 +6389,9 @@ public enum CumulativeGroupedAllocationCadence } sealed class CumulativeGroupedAllocationCadenceConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadence Read( + public override CumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6771,49 +6399,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .CumulativeGroupedAllocationCadence - .Annual, - "semi_annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .CumulativeGroupedAllocationCadence - .SemiAnnual, - "monthly" => global::Orb - .Models - .Beta - .ExternalPlanID - .CumulativeGroupedAllocationCadence - .Monthly, - "quarterly" => global::Orb - .Models - .Beta - .ExternalPlanID - .CumulativeGroupedAllocationCadence - .Quarterly, - "one_time" => global::Orb - .Models - .Beta - .ExternalPlanID - .CumulativeGroupedAllocationCadence - .OneTime, - "custom" => global::Orb - .Models - .Beta - .ExternalPlanID - .CumulativeGroupedAllocationCadence - .Custom, - _ => (global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadence)(-1), + "annual" => CumulativeGroupedAllocationCadence.Annual, + "semi_annual" => CumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => CumulativeGroupedAllocationCadence.Monthly, + "quarterly" => CumulativeGroupedAllocationCadence.Quarterly, + "one_time" => CumulativeGroupedAllocationCadence.OneTime, + "custom" => CumulativeGroupedAllocationCadence.Custom, + _ => (CumulativeGroupedAllocationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadence value, + CumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -6821,26 +6419,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadence.Annual => - "annual", - global::Orb - .Models - .Beta - .ExternalPlanID - .CumulativeGroupedAllocationCadence - .SemiAnnual => "semi_annual", - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadence.Monthly => - "monthly", - global::Orb - .Models - .Beta - .ExternalPlanID - .CumulativeGroupedAllocationCadence - .Quarterly => "quarterly", - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadence.OneTime => - "one_time", - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadence.Custom => - "custom", + CumulativeGroupedAllocationCadence.Annual => "annual", + CumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", + CumulativeGroupedAllocationCadence.Monthly => "monthly", + CumulativeGroupedAllocationCadence.Quarterly => "quarterly", + CumulativeGroupedAllocationCadence.OneTime => "one_time", + CumulativeGroupedAllocationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -6855,8 +6439,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfig, - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfigFromRaw + CumulativeGroupedAllocationConfig, + CumulativeGroupedAllocationConfigFromRaw >) )] public sealed record class CumulativeGroupedAllocationConfig : JsonModel @@ -6925,7 +6509,7 @@ public override void Validate() public CumulativeGroupedAllocationConfig() { } public CumulativeGroupedAllocationConfig( - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig ) : base(cumulativeGroupedAllocationConfig) { } @@ -6942,8 +6526,8 @@ public CumulativeGroupedAllocationConfig(IReadOnlyDictionary - public static global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6951,21 +6535,15 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class CumulativeGroupedAllocationConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfig FromRawUnchecked( + public CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfig.FromRawUnchecked( - rawData - ); + ) => CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfigConverter) -)] +[JsonConverter(typeof(CumulativeGroupedAllocationConversionRateConfigConverter))] public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -7124,11 +6702,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7153,9 +6731,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfig? other - ) + public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -7170,9 +6746,9 @@ public override string ToString() => } sealed class CumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfig? Read( + public override CumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7237,16 +6813,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfig( - element - ); + return new CumulativeGroupedAllocationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfig value, + CumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -7254,25 +6828,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.Minimum, - global::Orb.Models.Beta.ExternalPlanID.MinimumFromRaw - >) -)] -public sealed record class Minimum : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Percent : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } @@ -7291,44 +6858,42 @@ public required string ItemID } /// - /// Configuration for minimum pricing + /// The pricing model type /// - public required global::Orb.Models.Beta.ExternalPlanID.MinimumConfig MinimumConfig + public JsonElement ModelType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" - ); + return this._rawData.GetNotNullStruct("model_type"); } - init { this._rawData.Set("minimum_config", value); } + init { this._rawData.Set("model_type", value); } } /// - /// The pricing model type + /// The name of the price. /// - public JsonElement ModelType + public required string Name { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); + return this._rawData.GetNotNullClass("name"); } - init { this._rawData.Set("model_type", value); } + init { this._rawData.Set("name", value); } } /// - /// The name of the price. + /// Configuration for percent pricing /// - public required string Name + public required PercentConfig PercentConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); + return this._rawData.GetNotNullClass("percent_config"); } - init { this._rawData.Set("name", value); } + init { this._rawData.Set("percent_config", value); } } /// @@ -7390,12 +6955,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig? ConversionRateConfig + public PercentConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -7526,12 +7091,12 @@ public override void Validate() { this.Cadence.Validate(); _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("percent"))) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; + this.PercentConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -7547,51 +7112,48 @@ public override void Validate() _ = this.ReferenceID; } - public Minimum() + public Percent() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public Minimum(global::Orb.Models.Beta.ExternalPlanID.Minimum minimum) - : base(minimum) { } + public Percent(Percent percent) + : base(percent) { } - public Minimum(IReadOnlyDictionary rawData) + public Percent(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Minimum(FrozenDictionary rawData) + Percent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Percent FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class MinimumFromRaw : IFromRawJson +class PercentFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.Minimum.FromRawUnchecked(rawData); + public Percent FromRawUnchecked(IReadOnlyDictionary rawData) => + Percent.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.MinimumCadenceConverter))] -public enum MinimumCadence +[JsonConverter(typeof(PercentCadenceConverter))] +public enum PercentCadence { Annual, SemiAnnual, @@ -7601,10 +7163,9 @@ public enum MinimumCadence Custom, } -sealed class MinimumCadenceConverter - : JsonConverter +sealed class PercentCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.MinimumCadence Read( + public override PercentCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7612,19 +7173,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Beta.ExternalPlanID.MinimumCadence.Annual, - "semi_annual" => global::Orb.Models.Beta.ExternalPlanID.MinimumCadence.SemiAnnual, - "monthly" => global::Orb.Models.Beta.ExternalPlanID.MinimumCadence.Monthly, - "quarterly" => global::Orb.Models.Beta.ExternalPlanID.MinimumCadence.Quarterly, - "one_time" => global::Orb.Models.Beta.ExternalPlanID.MinimumCadence.OneTime, - "custom" => global::Orb.Models.Beta.ExternalPlanID.MinimumCadence.Custom, - _ => (global::Orb.Models.Beta.ExternalPlanID.MinimumCadence)(-1), + "annual" => PercentCadence.Annual, + "semi_annual" => PercentCadence.SemiAnnual, + "monthly" => PercentCadence.Monthly, + "quarterly" => PercentCadence.Quarterly, + "one_time" => PercentCadence.OneTime, + "custom" => PercentCadence.Custom, + _ => (PercentCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.MinimumCadence value, + PercentCadence value, JsonSerializerOptions options ) { @@ -7632,12 +7193,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Beta.ExternalPlanID.MinimumCadence.Annual => "annual", - global::Orb.Models.Beta.ExternalPlanID.MinimumCadence.SemiAnnual => "semi_annual", - global::Orb.Models.Beta.ExternalPlanID.MinimumCadence.Monthly => "monthly", - global::Orb.Models.Beta.ExternalPlanID.MinimumCadence.Quarterly => "quarterly", - global::Orb.Models.Beta.ExternalPlanID.MinimumCadence.OneTime => "one_time", - global::Orb.Models.Beta.ExternalPlanID.MinimumCadence.Custom => "custom", + PercentCadence.Annual => "annual", + PercentCadence.SemiAnnual => "semi_annual", + PercentCadence.Monthly => "monthly", + PercentCadence.Quarterly => "quarterly", + PercentCadence.OneTime => "one_time", + PercentCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -7648,101 +7209,71 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for percent pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.MinimumConfig, - global::Orb.Models.Beta.ExternalPlanID.MinimumConfigFromRaw - >) -)] -public sealed record class MinimumConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PercentConfig : JsonModel { /// - /// The minimum amount to apply - /// - public required string MinimumAmount - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); - } - init { this._rawData.Set("minimum_amount", value); } - } - - /// - /// If true, subtotals from this price are prorated based on the service period + /// What percent of the component subtotals to charge /// - public bool? Prorated + public required double Percent { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); - } - init - { - if (value == null) - { - return; - } - - this._rawData.Set("prorated", value); + return this._rawData.GetNotNullStruct("percent"); } + init { this._rawData.Set("percent", value); } } /// public override void Validate() { - _ = this.MinimumAmount; - _ = this.Prorated; + _ = this.Percent; } - public MinimumConfig() { } + public PercentConfig() { } - public MinimumConfig(global::Orb.Models.Beta.ExternalPlanID.MinimumConfig minimumConfig) - : base(minimumConfig) { } + public PercentConfig(PercentConfig percentConfig) + : base(percentConfig) { } - public MinimumConfig(IReadOnlyDictionary rawData) + public PercentConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - MinimumConfig(FrozenDictionary rawData) + PercentConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } [SetsRequiredMembers] - public MinimumConfig(string minimumAmount) + public PercentConfig(double percent) : this() { - this.MinimumAmount = minimumAmount; + this.Percent = percent; } } -class MinimumConfigFromRaw : IFromRawJson +class PercentConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.MinimumConfig.FromRawUnchecked(rawData); + public PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + PercentConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfigConverter))] -public record class MinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(PercentConversionRateConfigConverter))] +public record class PercentConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -7759,7 +7290,7 @@ public JsonElement Json } } - public MinimumConversionRateConfig( + public PercentConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7768,7 +7299,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig( + public PercentConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7777,7 +7308,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig(JsonElement element) + public PercentConversionRateConfig(JsonElement element) { this._element = element; } @@ -7859,7 +7390,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of PercentConversionRateConfig" ); } } @@ -7895,16 +7426,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of PercentConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7923,15 +7454,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of PercentConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig? other - ) + public virtual bool Equals(PercentConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -7945,10 +7474,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class MinimumConversionRateConfigConverter - : JsonConverter +sealed class PercentConversionRateConfigConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig? Read( + public override PercentConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8013,16 +7541,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig( - element - ); + return new PercentConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig value, + PercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -8030,29 +7556,35 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.Percent, - global::Orb.Models.Beta.ExternalPlanID.PercentFromRaw - >) -)] -public sealed record class Percent : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class EventOutput : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } + /// + /// Configuration for event_output pricing + /// + public required EventOutputConfig EventOutputConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("event_output_config"); + } + init { this._rawData.Set("event_output_config", value); } + } + /// /// The id of the item the price will be associated with. /// @@ -8092,21 +7624,6 @@ public required string Name init { this._rawData.Set("name", value); } } - /// - /// Configuration for percent pricing - /// - public required global::Orb.Models.Beta.ExternalPlanID.PercentConfig PercentConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "percent_config" - ); - } - init { this._rawData.Set("percent_config", value); } - } - /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -8166,12 +7683,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig? ConversionRateConfig + public EventOutputConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8301,13 +7818,18 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); + this.EventOutputConfig.Validate(); _ = this.ItemID; - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("percent"))) + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("event_output") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.PercentConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -8323,51 +7845,48 @@ public override void Validate() _ = this.ReferenceID; } - public Percent() + public EventOutput() { - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("event_output"); } - public Percent(global::Orb.Models.Beta.ExternalPlanID.Percent percent) - : base(percent) { } + public EventOutput(EventOutput eventOutput) + : base(eventOutput) { } - public Percent(IReadOnlyDictionary rawData) + public EventOutput(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("event_output"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Percent(FrozenDictionary rawData) + EventOutput(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PercentFromRaw : IFromRawJson +class EventOutputFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.Percent.FromRawUnchecked(rawData); + public EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutput.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.PercentCadenceConverter))] -public enum PercentCadence +[JsonConverter(typeof(EventOutputCadenceConverter))] +public enum EventOutputCadence { Annual, SemiAnnual, @@ -8377,10 +7896,9 @@ public enum PercentCadence Custom, } -sealed class PercentCadenceConverter - : JsonConverter +sealed class EventOutputCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.PercentCadence Read( + public override EventOutputCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8388,19 +7906,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Beta.ExternalPlanID.PercentCadence.Annual, - "semi_annual" => global::Orb.Models.Beta.ExternalPlanID.PercentCadence.SemiAnnual, - "monthly" => global::Orb.Models.Beta.ExternalPlanID.PercentCadence.Monthly, - "quarterly" => global::Orb.Models.Beta.ExternalPlanID.PercentCadence.Quarterly, - "one_time" => global::Orb.Models.Beta.ExternalPlanID.PercentCadence.OneTime, - "custom" => global::Orb.Models.Beta.ExternalPlanID.PercentCadence.Custom, - _ => (global::Orb.Models.Beta.ExternalPlanID.PercentCadence)(-1), + "annual" => EventOutputCadence.Annual, + "semi_annual" => EventOutputCadence.SemiAnnual, + "monthly" => EventOutputCadence.Monthly, + "quarterly" => EventOutputCadence.Quarterly, + "one_time" => EventOutputCadence.OneTime, + "custom" => EventOutputCadence.Custom, + _ => (EventOutputCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.PercentCadence value, + EventOutputCadence value, JsonSerializerOptions options ) { @@ -8408,12 +7926,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Beta.ExternalPlanID.PercentCadence.Annual => "annual", - global::Orb.Models.Beta.ExternalPlanID.PercentCadence.SemiAnnual => "semi_annual", - global::Orb.Models.Beta.ExternalPlanID.PercentCadence.Monthly => "monthly", - global::Orb.Models.Beta.ExternalPlanID.PercentCadence.Quarterly => "quarterly", - global::Orb.Models.Beta.ExternalPlanID.PercentCadence.OneTime => "one_time", - global::Orb.Models.Beta.ExternalPlanID.PercentCadence.Custom => "custom", + EventOutputCadence.Annual => "annual", + EventOutputCadence.SemiAnnual => "semi_annual", + EventOutputCadence.Monthly => "monthly", + EventOutputCadence.Quarterly => "quarterly", + EventOutputCadence.OneTime => "one_time", + EventOutputCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -8424,55 +7942,81 @@ JsonSerializerOptions options } /// -/// Configuration for percent pricing +/// Configuration for event_output pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.PercentConfig, - global::Orb.Models.Beta.ExternalPlanID.PercentConfigFromRaw - >) -)] -public sealed record class PercentConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class EventOutputConfig : JsonModel { /// - /// What percent of the component subtotals to charge + /// The key in the event data to extract the unit rate from. /// - public required double Percent + public required string UnitRatingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("percent"); + return this._rawData.GetNotNullClass("unit_rating_key"); } - init { this._rawData.Set("percent", value); } + init { this._rawData.Set("unit_rating_key", value); } + } + + /// + /// If provided, this amount will be used as the unit rate when an event does + /// not have a value for the `unit_rating_key`. If not provided, events missing + /// a unit rate will be ignored. + /// + public string? DefaultUnitRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("default_unit_rate"); + } + init { this._rawData.Set("default_unit_rate", value); } + } + + /// + /// An optional key in the event data to group by (e.g., event ID). All events + /// will also be grouped by their unit rate. + /// + public string? GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } } /// public override void Validate() { - _ = this.Percent; + _ = this.UnitRatingKey; + _ = this.DefaultUnitRate; + _ = this.GroupingKey; } - public PercentConfig() { } + public EventOutputConfig() { } - public PercentConfig(global::Orb.Models.Beta.ExternalPlanID.PercentConfig percentConfig) - : base(percentConfig) { } + public EventOutputConfig(EventOutputConfig eventOutputConfig) + : base(eventOutputConfig) { } - public PercentConfig(IReadOnlyDictionary rawData) + public EventOutputConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - PercentConfig(FrozenDictionary rawData) + EventOutputConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.PercentConfig FromRawUnchecked( + /// + public static EventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8480,23 +8024,22 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public PercentConfig(double percent) + public EventOutputConfig(string unitRatingKey) : this() { - this.Percent = percent; + this.UnitRatingKey = unitRatingKey; } } -class PercentConfigFromRaw : IFromRawJson +class EventOutputConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.PercentConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.PercentConfig.FromRawUnchecked(rawData); + public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutputConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfigConverter))] -public record class PercentConversionRateConfig : ModelBase +[JsonConverter(typeof(EventOutputConversionRateConfigConverter))] +public record class EventOutputConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -8513,7 +8056,7 @@ public JsonElement Json } } - public PercentConversionRateConfig( + public EventOutputConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8522,7 +8065,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig( + public EventOutputConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8531,7 +8074,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig(JsonElement element) + public EventOutputConversionRateConfig(JsonElement element) { this._element = element; } @@ -8613,7 +8156,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" + "Data did not match any variant of EventOutputConversionRateConfig" ); } } @@ -8649,16 +8192,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" + "Data did not match any variant of EventOutputConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -8677,15 +8220,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" + "Data did not match any variant of EventOutputConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig? other - ) + public virtual bool Equals(EventOutputConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -8699,10 +8240,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class PercentConversionRateConfigConverter - : JsonConverter +sealed class EventOutputConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig? Read( + public override EventOutputConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8767,16 +8308,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig( - element - ); + return new EventOutputConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig value, + EventOutputConversionRateConfig value, JsonSerializerOptions options ) { @@ -8784,332 +8323,228 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.EventOutput, - global::Orb.Models.Beta.ExternalPlanID.EventOutputFromRaw - >) -)] -public sealed record class EventOutput : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class RemoveAdjustment : JsonModel { /// - /// The cadence to bill for this price on. + /// The id of the adjustment to remove from on the plan. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence - > Cadence + public required string AdjustmentID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass("adjustment_id"); } - init { this._rawData.Set("cadence", value); } + init { this._rawData.Set("adjustment_id", value); } } /// - /// Configuration for event_output pricing + /// The phase to remove this adjustment from. /// - public required global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig EventOutputConfig + public long? PlanPhaseOrder { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "event_output_config" - ); + return this._rawData.GetNullableStruct("plan_phase_order"); } - init { this._rawData.Set("event_output_config", value); } + init { this._rawData.Set("plan_phase_order", value); } } - /// - /// The id of the item the price will be associated with. - /// - public required string ItemID + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); - } - init { this._rawData.Set("item_id", value); } + _ = this.AdjustmentID; + _ = this.PlanPhaseOrder; } - /// - /// The pricing model type - /// - public JsonElement ModelType + public RemoveAdjustment() { } + + public RemoveAdjustment(RemoveAdjustment removeAdjustment) + : base(removeAdjustment) { } + + public RemoveAdjustment(IReadOnlyDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); - } - init { this._rawData.Set("model_type", value); } + this._rawData = new(rawData); } - /// - /// The name of the price. - /// - public required string Name +#pragma warning disable CS8618 + [SetsRequiredMembers] + RemoveAdjustment(FrozenDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } + this._rawData = new(rawData); } +#pragma warning restore CS8618 - /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. - /// - public string? BillableMetricID + /// + public static RemoveAdjustment FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); - } - init { this._rawData.Set("billable_metric_id", value); } + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. - /// - public bool? BilledInAdvance + [SetsRequiredMembers] + public RemoveAdjustment(string adjustmentID) + : this() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); - } - init { this._rawData.Set("billed_in_advance", value); } + this.AdjustmentID = adjustmentID; } +} + +class RemoveAdjustmentFromRaw : IFromRawJson +{ + /// + public RemoveAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => + RemoveAdjustment.FromRawUnchecked(rawData); +} +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class RemovePrice : JsonModel +{ /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. + /// The id of the price to remove from the plan. /// - public NewBillingCycleConfiguration? BillingCycleConfiguration + public required string PriceID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); + return this._rawData.GetNotNullClass("price_id"); } - init { this._rawData.Set("billing_cycle_configuration", value); } + init { this._rawData.Set("price_id", value); } } /// - /// The per unit conversion rate of the price currency to the invoicing currency. + /// The phase to remove this price from. /// - public double? ConversionRate + public long? PlanPhaseOrder { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); + return this._rawData.GetNullableStruct("plan_phase_order"); } - init { this._rawData.Set("conversion_rate", value); } + init { this._rawData.Set("plan_phase_order", value); } } - /// - /// The configuration for the rate of the price currency to the invoicing currency. - /// - public global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig? ConversionRateConfig + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", value); } + _ = this.PriceID; + _ = this.PlanPhaseOrder; } - /// - /// An ISO 4217 currency string, or custom pricing unit identifier, in which - /// this price is billed. - /// - public string? Currency + public RemovePrice() { } + + public RemovePrice(RemovePrice removePrice) + : base(removePrice) { } + + public RemovePrice(IReadOnlyDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("currency"); - } - init { this._rawData.Set("currency", value); } + this._rawData = new(rawData); } - /// - /// For dimensional price: specifies a price group and dimension values - /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration +#pragma warning disable CS8618 + [SetsRequiredMembers] + RemovePrice(FrozenDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } + this._rawData = new(rawData); } +#pragma warning restore CS8618 - /// - /// An alias for the price. - /// - public string? ExternalPriceID + /// + public static RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. - /// - public double? FixedPriceQuantity + [SetsRequiredMembers] + public RemovePrice(string priceID) + : this() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } + this.PriceID = priceID; } +} + +class RemovePriceFromRaw : IFromRawJson +{ + /// + public RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) => + RemovePrice.FromRawUnchecked(rawData); +} +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ReplaceAdjustment : JsonModel +{ /// - /// The property used to group this price on an invoice + /// The definition of a new adjustment to create and add to the plan. /// - public string? InvoiceGroupingKey + public required ReplaceAdjustmentAdjustment Adjustment { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); + return this._rawData.GetNotNullClass("adjustment"); } - init { this._rawData.Set("invoice_grouping_key", value); } + init { this._rawData.Set("adjustment", value); } } /// - /// Within each billing cycle, specifies the cadence at which invoices are produced. - /// If unspecified, a single invoice is produced per billing cycle. + /// The id of the adjustment on the plan to replace in the plan. /// - public NewBillingCycleConfiguration? InvoicingCycleConfiguration + public required string ReplacesAdjustmentID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); + return this._rawData.GetNotNullClass("replaces_adjustment_id"); } - init { this._rawData.Set("invoicing_cycle_configuration", value); } + init { this._rawData.Set("replaces_adjustment_id", value); } } /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared - /// by setting `metadata` to `null`. + /// The phase to replace this adjustment from. /// - public IReadOnlyDictionary? Metadata + public long? PlanPhaseOrder { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) - ); + return this._rawData.GetNullableStruct("plan_phase_order"); } + init { this._rawData.Set("plan_phase_order", value); } } - /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. - /// - public string? ReferenceID + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("reference_id"); - } - init { this._rawData.Set("reference_id", value); } - } - - /// - public override void Validate() - { - this.Cadence.Validate(); - this.EventOutputConfig.Validate(); - _ = this.ItemID; - if ( - !JsonElement.DeepEquals( - this.ModelType, - JsonSerializer.SerializeToElement("event_output") - ) - ) - { - throw new OrbInvalidDataException("Invalid value given for constant"); - } - _ = this.Name; - _ = this.BillableMetricID; - _ = this.BilledInAdvance; - this.BillingCycleConfiguration?.Validate(); - _ = this.ConversionRate; - this.ConversionRateConfig?.Validate(); - _ = this.Currency; - this.DimensionalPriceConfiguration?.Validate(); - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.InvoiceGroupingKey; - this.InvoicingCycleConfiguration?.Validate(); - _ = this.Metadata; - _ = this.ReferenceID; + this.Adjustment.Validate(); + _ = this.ReplacesAdjustmentID; + _ = this.PlanPhaseOrder; } - public EventOutput() - { - this.ModelType = JsonSerializer.SerializeToElement("event_output"); - } + public ReplaceAdjustment() { } - public EventOutput(global::Orb.Models.Beta.ExternalPlanID.EventOutput eventOutput) - : base(eventOutput) { } + public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) + : base(replaceAdjustment) { } - public EventOutput(IReadOnlyDictionary rawData) + public ReplaceAdjustment(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("event_output"); } #pragma warning disable CS8618 [SetsRequiredMembers] - EventOutput(FrozenDictionary rawData) + ReplaceAdjustment(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.EventOutput FromRawUnchecked( + /// + public static ReplaceAdjustment FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9117,302 +8552,253 @@ IReadOnlyDictionary rawData } } -class EventOutputFromRaw : IFromRawJson +class ReplaceAdjustmentFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.EventOutput FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.EventOutput.FromRawUnchecked(rawData); + public ReplaceAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => + ReplaceAdjustment.FromRawUnchecked(rawData); } /// -/// The cadence to bill for this price on. +/// The definition of a new adjustment to create and add to the plan. /// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.EventOutputCadenceConverter))] -public enum EventOutputCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class EventOutputCadenceConverter - : JsonConverter +[JsonConverter(typeof(ReplaceAdjustmentAdjustmentConverter))] +public record class ReplaceAdjustmentAdjustment : ModelBase { - public override global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence.Annual, - "semi_annual" => global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence.SemiAnnual, - "monthly" => global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence.Monthly, - "quarterly" => global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence.Quarterly, - "one_time" => global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence.OneTime, - "custom" => global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence.Custom, - _ => (global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence)(-1), - }; - } + public object? Value { get; } = null; - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence.Annual => "annual", - global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence.SemiAnnual => - "semi_annual", - global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence.Monthly => "monthly", - global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence.Quarterly => "quarterly", - global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence.OneTime => "one_time", - global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} + JsonElement? _element = null; -/// -/// Configuration for event_output pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig, - global::Orb.Models.Beta.ExternalPlanID.EventOutputConfigFromRaw - >) -)] -public sealed record class EventOutputConfig : JsonModel -{ - /// - /// The key in the event data to extract the unit rate from. - /// - public required string UnitRatingKey + public JsonElement Json { get { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_rating_key"); + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); } - init { this._rawData.Set("unit_rating_key", value); } } - /// - /// If provided, this amount will be used as the unit rate when an event does - /// not have a value for the `unit_rating_key`. If not provided, events missing - /// a unit rate will be ignored. - /// - public string? DefaultUnitRate + public string? Currency { get { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("default_unit_rate"); + return Match( + newPercentageDiscount: (x) => x.Currency, + newUsageDiscount: (x) => x.Currency, + newAmountDiscount: (x) => x.Currency, + newMinimum: (x) => x.Currency, + newMaximum: (x) => x.Currency + ); } - init { this._rawData.Set("default_unit_rate", value); } } - /// - /// An optional key in the event data to group by (e.g., event ID). All events - /// will also be grouped by their unit rate. - /// - public string? GroupingKey + public bool? IsInvoiceLevel { get { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("grouping_key"); + return Match( + newPercentageDiscount: (x) => x.IsInvoiceLevel, + newUsageDiscount: (x) => x.IsInvoiceLevel, + newAmountDiscount: (x) => x.IsInvoiceLevel, + newMinimum: (x) => x.IsInvoiceLevel, + newMaximum: (x) => x.IsInvoiceLevel + ); } - init { this._rawData.Set("grouping_key", value); } - } - - /// - public override void Validate() - { - _ = this.UnitRatingKey; - _ = this.DefaultUnitRate; - _ = this.GroupingKey; - } - - public EventOutputConfig() { } - - public EventOutputConfig( - global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig eventOutputConfig - ) - : base(eventOutputConfig) { } - - public EventOutputConfig(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - EventOutputConfig(FrozenDictionary rawData) - { - this._rawData = new(rawData); } -#pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + public ReplaceAdjustmentAdjustment(NewPercentageDiscount value, JsonElement? element = null) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this.Value = value; + this._element = element; } - [SetsRequiredMembers] - public EventOutputConfig(string unitRatingKey) - : this() + public ReplaceAdjustmentAdjustment(NewUsageDiscount value, JsonElement? element = null) { - this.UnitRatingKey = unitRatingKey; + this.Value = value; + this._element = element; } -} - -class EventOutputConfigFromRaw - : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig.FromRawUnchecked(rawData); -} - -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfigConverter) -)] -public record class EventOutputConversionRateConfig : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - public JsonElement Json + public ReplaceAdjustmentAdjustment(NewAmountDiscount value, JsonElement? element = null) { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } + this.Value = value; + this._element = element; } - public EventOutputConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) + public ReplaceAdjustmentAdjustment(NewMinimum value, JsonElement? element = null) { this.Value = value; this._element = element; } - public EventOutputConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) + public ReplaceAdjustmentAdjustment(NewMaximum value, JsonElement? element = null) { this.Value = value; this._element = element; } - public EventOutputConversionRateConfig(JsonElement element) + public ReplaceAdjustmentAdjustment(JsonElement element) { this._element = element; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` + /// if (instance.TryPickNewPercentageDiscount(out var value)) { + /// // `value` is of type `NewPercentageDiscount` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) { - value = this.Value as SharedUnitConversionRateConfig; + value = this.Value as NewPercentageDiscount; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` + /// if (instance.TryPickNewUsageDiscount(out var value)) { + /// // `value` is of type `NewUsageDiscount` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) { - value = this.Value as SharedTieredConversionRateConfig; + value = this.Value as NewUsageDiscount; return value != null; } /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// + /// Consider using or if you need to handle every variant. /// /// /// - /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// if (instance.TryPickNewAmountDiscount(out var value)) { + /// // `value` is of type `NewAmountDiscount` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) + { + value = this.Value as NewAmountDiscount; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewMinimum(out var value)) { + /// // `value` is of type `NewMinimum` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? value) + { + value = this.Value as NewMinimum; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewMaximum(out var value)) { + /// // `value` is of type `NewMaximum` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) + { + value = this.Value as NewMaximum; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// /// public void Switch( - System::Action unit, - System::Action tiered + System::Action newPercentageDiscount, + System::Action newUsageDiscount, + System::Action newAmountDiscount, + System::Action newMinimum, + System::Action newMaximum ) { switch (this.Value) { - case SharedUnitConversionRateConfig value: - unit(value); + case NewPercentageDiscount value: + newPercentageDiscount(value); break; - case SharedTieredConversionRateConfig value: - tiered(value); + case NewUsageDiscount value: + newUsageDiscount(value); + break; + case NewAmountDiscount value: + newAmountDiscount(value); + break; + case NewMinimum value: + newMinimum(value); + break; + case NewMaximum value: + newMaximum(value); break; default: throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + "Data did not match any variant of ReplaceAdjustmentAdjustment" ); } } @@ -9432,34 +8818,48 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// /// public T Match( - System::Func unit, - System::Func tiered + System::Func newPercentageDiscount, + System::Func newUsageDiscount, + System::Func newAmountDiscount, + System::Func newMinimum, + System::Func newMaximum ) { return this.Value switch { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), + NewPercentageDiscount value => newPercentageDiscount(value), + NewUsageDiscount value => newUsageDiscount(value), + NewAmountDiscount value => newAmountDiscount(value), + NewMinimum value => newMinimum(value), + NewMaximum value => newMaximum(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + "Data did not match any variant of ReplaceAdjustmentAdjustment" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); + public static implicit operator ReplaceAdjustmentAdjustment(NewPercentageDiscount value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); + public static implicit operator ReplaceAdjustmentAdjustment(NewUsageDiscount value) => + new(value); + + public static implicit operator ReplaceAdjustmentAdjustment(NewAmountDiscount value) => + new(value); + + public static implicit operator ReplaceAdjustmentAdjustment(NewMinimum value) => new(value); + + public static implicit operator ReplaceAdjustmentAdjustment(NewMaximum value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -9476,15 +8876,19 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + "Data did not match any variant of ReplaceAdjustmentAdjustment" ); } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + this.Switch( + (newPercentageDiscount) => newPercentageDiscount.Validate(), + (newUsageDiscount) => newUsageDiscount.Validate(), + (newAmountDiscount) => newAmountDiscount.Validate(), + (newMinimum) => newMinimum.Validate(), + (newMaximum) => newMaximum.Validate() + ); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig? other - ) + public virtual bool Equals(ReplaceAdjustmentAdjustment? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -9498,33 +8902,32 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class EventOutputConversionRateConfigConverter - : JsonConverter +sealed class ReplaceAdjustmentAdjustmentConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig? Read( + public override ReplaceAdjustmentAdjustment? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options ) { var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; + string? adjustmentType; try { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); + adjustmentType = element.GetProperty("adjustment_type").GetString(); } catch { - conversionRateType = null; + adjustmentType = null; } - switch (conversionRateType) + switch (adjustmentType) { - case "unit": + case "percentage_discount": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -9542,11 +8945,33 @@ JsonSerializerOptions options return new(element); } - case "tiered": + case "usage_discount": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } + + return new(element); + } + case "amount_discount": + { + try + { + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -9564,18 +8989,54 @@ JsonSerializerOptions options return new(element); } + case "minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } + + return new(element); + } + case "maximum": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } + + return new(element); + } default: { - return new global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig( - element - ); + return new ReplaceAdjustmentAdjustment(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig value, + ReplaceAdjustmentAdjustment value, JsonSerializerOptions options ) { @@ -9583,29 +9044,37 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustment, - global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustmentFromRaw - >) -)] -public sealed record class RemoveAdjustment : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ReplacePrice : JsonModel { /// - /// The id of the adjustment to remove from on the plan. + /// The id of the price on the plan to replace in the plan. /// - public required string AdjustmentID + public required string ReplacesPriceID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment_id"); + return this._rawData.GetNotNullClass("replaces_price_id"); } - init { this._rawData.Set("adjustment_id", value); } + init { this._rawData.Set("replaces_price_id", value); } } /// - /// The phase to remove this adjustment from. + /// The allocation price to add to the plan. + /// + public NewAllocationPrice? AllocationPrice + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("allocation_price"); + } + init { this._rawData.Set("allocation_price", value); } + } + + /// + /// The phase to replace this price from. /// public long? PlanPhaseOrder { @@ -9617,241 +9086,72 @@ public long? PlanPhaseOrder init { this._rawData.Set("plan_phase_order", value); } } - /// - public override void Validate() - { - _ = this.AdjustmentID; - _ = this.PlanPhaseOrder; - } - - public RemoveAdjustment() { } - - public RemoveAdjustment( - global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustment removeAdjustment - ) - : base(removeAdjustment) { } - - public RemoveAdjustment(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemoveAdjustment(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public RemoveAdjustment(string adjustmentID) - : this() - { - this.AdjustmentID = adjustmentID; - } -} - -class RemoveAdjustmentFromRaw - : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustment.FromRawUnchecked(rawData); -} - -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.RemovePrice, - global::Orb.Models.Beta.ExternalPlanID.RemovePriceFromRaw - >) -)] -public sealed record class RemovePrice : JsonModel -{ - /// - /// The id of the price to remove from the plan. - /// - public required string PriceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("price_id"); - } - init { this._rawData.Set("price_id", value); } - } - - /// - /// The phase to remove this price from. - /// - public long? PlanPhaseOrder + /// + /// New plan price request body params. + /// + public ReplacePricePrice? Price { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); + return this._rawData.GetNullableClass("price"); } - init { this._rawData.Set("plan_phase_order", value); } + init { this._rawData.Set("price", value); } } /// public override void Validate() { - _ = this.PriceID; + _ = this.ReplacesPriceID; + this.AllocationPrice?.Validate(); _ = this.PlanPhaseOrder; + this.Price?.Validate(); } - public RemovePrice() { } + public ReplacePrice() { } - public RemovePrice(global::Orb.Models.Beta.ExternalPlanID.RemovePrice removePrice) - : base(removePrice) { } + public ReplacePrice(ReplacePrice replacePrice) + : base(replacePrice) { } - public RemovePrice(IReadOnlyDictionary rawData) + public ReplacePrice(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - RemovePrice(FrozenDictionary rawData) + ReplacePrice(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.RemovePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } [SetsRequiredMembers] - public RemovePrice(string priceID) + public ReplacePrice(string replacesPriceID) : this() { - this.PriceID = priceID; - } -} - -class RemovePriceFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.RemovePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.RemovePrice.FromRawUnchecked(rawData); -} - -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustment, - global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentFromRaw - >) -)] -public sealed record class ReplaceAdjustment : JsonModel -{ - /// - /// The definition of a new adjustment to create and add to the plan. - /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment Adjustment - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "adjustment" - ); - } - init { this._rawData.Set("adjustment", value); } - } - - /// - /// The id of the adjustment on the plan to replace in the plan. - /// - public required string ReplacesAdjustmentID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_adjustment_id"); - } - init { this._rawData.Set("replaces_adjustment_id", value); } - } - - /// - /// The phase to replace this adjustment from. - /// - public long? PlanPhaseOrder - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); - } - init { this._rawData.Set("plan_phase_order", value); } - } - - /// - public override void Validate() - { - this.Adjustment.Validate(); - _ = this.ReplacesAdjustmentID; - _ = this.PlanPhaseOrder; - } - - public ReplaceAdjustment() { } - - public ReplaceAdjustment( - global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustment replaceAdjustment - ) - : base(replaceAdjustment) { } - - public ReplaceAdjustment(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplaceAdjustment(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this.ReplacesPriceID = replacesPriceID; } } -class ReplaceAdjustmentFromRaw - : IFromRawJson +class ReplacePriceFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustment.FromRawUnchecked(rawData); + public ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) => + ReplacePrice.FromRawUnchecked(rawData); } /// -/// The definition of a new adjustment to create and add to the plan. +/// New plan price request body params. /// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustmentConverter))] -public record class ReplaceAdjustmentAdjustment : ModelBase +[JsonConverter(typeof(ReplacePricePriceConverter))] +public record class ReplacePricePrice : ModelBase { public object? Value { get; } = null; @@ -9868,4427 +9168,2601 @@ public JsonElement Json } } - public string? Currency + public string ItemID { get { - return Match( - newPercentageDiscount: (x) => x.Currency, - newUsageDiscount: (x) => x.Currency, - newAmountDiscount: (x) => x.Currency, - newMinimum: (x) => x.Currency, - newMaximum: (x) => x.Currency + return Match( + newPlanUnit: (x) => x.ItemID, + newPlanTiered: (x) => x.ItemID, + newPlanBulk: (x) => x.ItemID, + bulkWithFilters: (x) => x.ItemID, + newPlanPackage: (x) => x.ItemID, + newPlanMatrix: (x) => x.ItemID, + newPlanThresholdTotalAmount: (x) => x.ItemID, + newPlanTieredPackage: (x) => x.ItemID, + newPlanTieredWithMinimum: (x) => x.ItemID, + newPlanGroupedTiered: (x) => x.ItemID, + newPlanTieredPackageWithMinimum: (x) => x.ItemID, + newPlanPackageWithAllocation: (x) => x.ItemID, + newPlanUnitWithPercent: (x) => x.ItemID, + newPlanMatrixWithAllocation: (x) => x.ItemID, + tieredWithProration: (x) => x.ItemID, + newPlanUnitWithProration: (x) => x.ItemID, + newPlanGroupedAllocation: (x) => x.ItemID, + newPlanBulkWithProration: (x) => x.ItemID, + newPlanGroupedWithProratedMinimum: (x) => x.ItemID, + newPlanGroupedWithMeteredMinimum: (x) => x.ItemID, + groupedWithMinMaxThresholds: (x) => x.ItemID, + newPlanMatrixWithDisplayName: (x) => x.ItemID, + newPlanGroupedTieredPackage: (x) => x.ItemID, + newPlanMaxGroupTieredPackage: (x) => x.ItemID, + newPlanScalableMatrixWithUnitPricing: (x) => x.ItemID, + newPlanScalableMatrixWithTieredPricing: (x) => x.ItemID, + newPlanCumulativeGroupedBulk: (x) => x.ItemID, + cumulativeGroupedAllocation: (x) => x.ItemID, + newPlanMinimumComposite: (x) => x.ItemID, + percent: (x) => x.ItemID, + eventOutput: (x) => x.ItemID ); } } - public bool? IsInvoiceLevel + public string Name { get { - return Match( - newPercentageDiscount: (x) => x.IsInvoiceLevel, - newUsageDiscount: (x) => x.IsInvoiceLevel, - newAmountDiscount: (x) => x.IsInvoiceLevel, - newMinimum: (x) => x.IsInvoiceLevel, - newMaximum: (x) => x.IsInvoiceLevel + return Match( + newPlanUnit: (x) => x.Name, + newPlanTiered: (x) => x.Name, + newPlanBulk: (x) => x.Name, + bulkWithFilters: (x) => x.Name, + newPlanPackage: (x) => x.Name, + newPlanMatrix: (x) => x.Name, + newPlanThresholdTotalAmount: (x) => x.Name, + newPlanTieredPackage: (x) => x.Name, + newPlanTieredWithMinimum: (x) => x.Name, + newPlanGroupedTiered: (x) => x.Name, + newPlanTieredPackageWithMinimum: (x) => x.Name, + newPlanPackageWithAllocation: (x) => x.Name, + newPlanUnitWithPercent: (x) => x.Name, + newPlanMatrixWithAllocation: (x) => x.Name, + tieredWithProration: (x) => x.Name, + newPlanUnitWithProration: (x) => x.Name, + newPlanGroupedAllocation: (x) => x.Name, + newPlanBulkWithProration: (x) => x.Name, + newPlanGroupedWithProratedMinimum: (x) => x.Name, + newPlanGroupedWithMeteredMinimum: (x) => x.Name, + groupedWithMinMaxThresholds: (x) => x.Name, + newPlanMatrixWithDisplayName: (x) => x.Name, + newPlanGroupedTieredPackage: (x) => x.Name, + newPlanMaxGroupTieredPackage: (x) => x.Name, + newPlanScalableMatrixWithUnitPricing: (x) => x.Name, + newPlanScalableMatrixWithTieredPricing: (x) => x.Name, + newPlanCumulativeGroupedBulk: (x) => x.Name, + cumulativeGroupedAllocation: (x) => x.Name, + newPlanMinimumComposite: (x) => x.Name, + percent: (x) => x.Name, + eventOutput: (x) => x.Name ); } } - public ReplaceAdjustmentAdjustment(NewPercentageDiscount value, JsonElement? element = null) + public string? BillableMetricID { - this.Value = value; - this._element = element; + get + { + return Match( + newPlanUnit: (x) => x.BillableMetricID, + newPlanTiered: (x) => x.BillableMetricID, + newPlanBulk: (x) => x.BillableMetricID, + bulkWithFilters: (x) => x.BillableMetricID, + newPlanPackage: (x) => x.BillableMetricID, + newPlanMatrix: (x) => x.BillableMetricID, + newPlanThresholdTotalAmount: (x) => x.BillableMetricID, + newPlanTieredPackage: (x) => x.BillableMetricID, + newPlanTieredWithMinimum: (x) => x.BillableMetricID, + newPlanGroupedTiered: (x) => x.BillableMetricID, + newPlanTieredPackageWithMinimum: (x) => x.BillableMetricID, + newPlanPackageWithAllocation: (x) => x.BillableMetricID, + newPlanUnitWithPercent: (x) => x.BillableMetricID, + newPlanMatrixWithAllocation: (x) => x.BillableMetricID, + tieredWithProration: (x) => x.BillableMetricID, + newPlanUnitWithProration: (x) => x.BillableMetricID, + newPlanGroupedAllocation: (x) => x.BillableMetricID, + newPlanBulkWithProration: (x) => x.BillableMetricID, + newPlanGroupedWithProratedMinimum: (x) => x.BillableMetricID, + newPlanGroupedWithMeteredMinimum: (x) => x.BillableMetricID, + groupedWithMinMaxThresholds: (x) => x.BillableMetricID, + newPlanMatrixWithDisplayName: (x) => x.BillableMetricID, + newPlanGroupedTieredPackage: (x) => x.BillableMetricID, + newPlanMaxGroupTieredPackage: (x) => x.BillableMetricID, + newPlanScalableMatrixWithUnitPricing: (x) => x.BillableMetricID, + newPlanScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, + newPlanCumulativeGroupedBulk: (x) => x.BillableMetricID, + cumulativeGroupedAllocation: (x) => x.BillableMetricID, + newPlanMinimumComposite: (x) => x.BillableMetricID, + percent: (x) => x.BillableMetricID, + eventOutput: (x) => x.BillableMetricID + ); + } } - public ReplaceAdjustmentAdjustment(NewUsageDiscount value, JsonElement? element = null) + public bool? BilledInAdvance { - this.Value = value; - this._element = element; + get + { + return Match( + newPlanUnit: (x) => x.BilledInAdvance, + newPlanTiered: (x) => x.BilledInAdvance, + newPlanBulk: (x) => x.BilledInAdvance, + bulkWithFilters: (x) => x.BilledInAdvance, + newPlanPackage: (x) => x.BilledInAdvance, + newPlanMatrix: (x) => x.BilledInAdvance, + newPlanThresholdTotalAmount: (x) => x.BilledInAdvance, + newPlanTieredPackage: (x) => x.BilledInAdvance, + newPlanTieredWithMinimum: (x) => x.BilledInAdvance, + newPlanGroupedTiered: (x) => x.BilledInAdvance, + newPlanTieredPackageWithMinimum: (x) => x.BilledInAdvance, + newPlanPackageWithAllocation: (x) => x.BilledInAdvance, + newPlanUnitWithPercent: (x) => x.BilledInAdvance, + newPlanMatrixWithAllocation: (x) => x.BilledInAdvance, + tieredWithProration: (x) => x.BilledInAdvance, + newPlanUnitWithProration: (x) => x.BilledInAdvance, + newPlanGroupedAllocation: (x) => x.BilledInAdvance, + newPlanBulkWithProration: (x) => x.BilledInAdvance, + newPlanGroupedWithProratedMinimum: (x) => x.BilledInAdvance, + newPlanGroupedWithMeteredMinimum: (x) => x.BilledInAdvance, + groupedWithMinMaxThresholds: (x) => x.BilledInAdvance, + newPlanMatrixWithDisplayName: (x) => x.BilledInAdvance, + newPlanGroupedTieredPackage: (x) => x.BilledInAdvance, + newPlanMaxGroupTieredPackage: (x) => x.BilledInAdvance, + newPlanScalableMatrixWithUnitPricing: (x) => x.BilledInAdvance, + newPlanScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, + newPlanCumulativeGroupedBulk: (x) => x.BilledInAdvance, + cumulativeGroupedAllocation: (x) => x.BilledInAdvance, + newPlanMinimumComposite: (x) => x.BilledInAdvance, + percent: (x) => x.BilledInAdvance, + eventOutput: (x) => x.BilledInAdvance + ); + } } - public ReplaceAdjustmentAdjustment(NewAmountDiscount value, JsonElement? element = null) + public NewBillingCycleConfiguration? BillingCycleConfiguration { - this.Value = value; - this._element = element; + get + { + return Match( + newPlanUnit: (x) => x.BillingCycleConfiguration, + newPlanTiered: (x) => x.BillingCycleConfiguration, + newPlanBulk: (x) => x.BillingCycleConfiguration, + bulkWithFilters: (x) => x.BillingCycleConfiguration, + newPlanPackage: (x) => x.BillingCycleConfiguration, + newPlanMatrix: (x) => x.BillingCycleConfiguration, + newPlanThresholdTotalAmount: (x) => x.BillingCycleConfiguration, + newPlanTieredPackage: (x) => x.BillingCycleConfiguration, + newPlanTieredWithMinimum: (x) => x.BillingCycleConfiguration, + newPlanGroupedTiered: (x) => x.BillingCycleConfiguration, + newPlanTieredPackageWithMinimum: (x) => x.BillingCycleConfiguration, + newPlanPackageWithAllocation: (x) => x.BillingCycleConfiguration, + newPlanUnitWithPercent: (x) => x.BillingCycleConfiguration, + newPlanMatrixWithAllocation: (x) => x.BillingCycleConfiguration, + tieredWithProration: (x) => x.BillingCycleConfiguration, + newPlanUnitWithProration: (x) => x.BillingCycleConfiguration, + newPlanGroupedAllocation: (x) => x.BillingCycleConfiguration, + newPlanBulkWithProration: (x) => x.BillingCycleConfiguration, + newPlanGroupedWithProratedMinimum: (x) => x.BillingCycleConfiguration, + newPlanGroupedWithMeteredMinimum: (x) => x.BillingCycleConfiguration, + groupedWithMinMaxThresholds: (x) => x.BillingCycleConfiguration, + newPlanMatrixWithDisplayName: (x) => x.BillingCycleConfiguration, + newPlanGroupedTieredPackage: (x) => x.BillingCycleConfiguration, + newPlanMaxGroupTieredPackage: (x) => x.BillingCycleConfiguration, + newPlanScalableMatrixWithUnitPricing: (x) => x.BillingCycleConfiguration, + newPlanScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, + newPlanCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, + cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, + newPlanMinimumComposite: (x) => x.BillingCycleConfiguration, + percent: (x) => x.BillingCycleConfiguration, + eventOutput: (x) => x.BillingCycleConfiguration + ); + } } - public ReplaceAdjustmentAdjustment(NewMinimum value, JsonElement? element = null) + public double? ConversionRate { - this.Value = value; - this._element = element; + get + { + return Match( + newPlanUnit: (x) => x.ConversionRate, + newPlanTiered: (x) => x.ConversionRate, + newPlanBulk: (x) => x.ConversionRate, + bulkWithFilters: (x) => x.ConversionRate, + newPlanPackage: (x) => x.ConversionRate, + newPlanMatrix: (x) => x.ConversionRate, + newPlanThresholdTotalAmount: (x) => x.ConversionRate, + newPlanTieredPackage: (x) => x.ConversionRate, + newPlanTieredWithMinimum: (x) => x.ConversionRate, + newPlanGroupedTiered: (x) => x.ConversionRate, + newPlanTieredPackageWithMinimum: (x) => x.ConversionRate, + newPlanPackageWithAllocation: (x) => x.ConversionRate, + newPlanUnitWithPercent: (x) => x.ConversionRate, + newPlanMatrixWithAllocation: (x) => x.ConversionRate, + tieredWithProration: (x) => x.ConversionRate, + newPlanUnitWithProration: (x) => x.ConversionRate, + newPlanGroupedAllocation: (x) => x.ConversionRate, + newPlanBulkWithProration: (x) => x.ConversionRate, + newPlanGroupedWithProratedMinimum: (x) => x.ConversionRate, + newPlanGroupedWithMeteredMinimum: (x) => x.ConversionRate, + groupedWithMinMaxThresholds: (x) => x.ConversionRate, + newPlanMatrixWithDisplayName: (x) => x.ConversionRate, + newPlanGroupedTieredPackage: (x) => x.ConversionRate, + newPlanMaxGroupTieredPackage: (x) => x.ConversionRate, + newPlanScalableMatrixWithUnitPricing: (x) => x.ConversionRate, + newPlanScalableMatrixWithTieredPricing: (x) => x.ConversionRate, + newPlanCumulativeGroupedBulk: (x) => x.ConversionRate, + cumulativeGroupedAllocation: (x) => x.ConversionRate, + newPlanMinimumComposite: (x) => x.ConversionRate, + percent: (x) => x.ConversionRate, + eventOutput: (x) => x.ConversionRate + ); + } } - public ReplaceAdjustmentAdjustment(NewMaximum value, JsonElement? element = null) + public string? Currency { - this.Value = value; - this._element = element; + get + { + return Match( + newPlanUnit: (x) => x.Currency, + newPlanTiered: (x) => x.Currency, + newPlanBulk: (x) => x.Currency, + bulkWithFilters: (x) => x.Currency, + newPlanPackage: (x) => x.Currency, + newPlanMatrix: (x) => x.Currency, + newPlanThresholdTotalAmount: (x) => x.Currency, + newPlanTieredPackage: (x) => x.Currency, + newPlanTieredWithMinimum: (x) => x.Currency, + newPlanGroupedTiered: (x) => x.Currency, + newPlanTieredPackageWithMinimum: (x) => x.Currency, + newPlanPackageWithAllocation: (x) => x.Currency, + newPlanUnitWithPercent: (x) => x.Currency, + newPlanMatrixWithAllocation: (x) => x.Currency, + tieredWithProration: (x) => x.Currency, + newPlanUnitWithProration: (x) => x.Currency, + newPlanGroupedAllocation: (x) => x.Currency, + newPlanBulkWithProration: (x) => x.Currency, + newPlanGroupedWithProratedMinimum: (x) => x.Currency, + newPlanGroupedWithMeteredMinimum: (x) => x.Currency, + groupedWithMinMaxThresholds: (x) => x.Currency, + newPlanMatrixWithDisplayName: (x) => x.Currency, + newPlanGroupedTieredPackage: (x) => x.Currency, + newPlanMaxGroupTieredPackage: (x) => x.Currency, + newPlanScalableMatrixWithUnitPricing: (x) => x.Currency, + newPlanScalableMatrixWithTieredPricing: (x) => x.Currency, + newPlanCumulativeGroupedBulk: (x) => x.Currency, + cumulativeGroupedAllocation: (x) => x.Currency, + newPlanMinimumComposite: (x) => x.Currency, + percent: (x) => x.Currency, + eventOutput: (x) => x.Currency + ); + } } - public ReplaceAdjustmentAdjustment(JsonElement element) + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { - this._element = element; + get + { + return Match( + newPlanUnit: (x) => x.DimensionalPriceConfiguration, + newPlanTiered: (x) => x.DimensionalPriceConfiguration, + newPlanBulk: (x) => x.DimensionalPriceConfiguration, + bulkWithFilters: (x) => x.DimensionalPriceConfiguration, + newPlanPackage: (x) => x.DimensionalPriceConfiguration, + newPlanMatrix: (x) => x.DimensionalPriceConfiguration, + newPlanThresholdTotalAmount: (x) => x.DimensionalPriceConfiguration, + newPlanTieredPackage: (x) => x.DimensionalPriceConfiguration, + newPlanTieredWithMinimum: (x) => x.DimensionalPriceConfiguration, + newPlanGroupedTiered: (x) => x.DimensionalPriceConfiguration, + newPlanTieredPackageWithMinimum: (x) => x.DimensionalPriceConfiguration, + newPlanPackageWithAllocation: (x) => x.DimensionalPriceConfiguration, + newPlanUnitWithPercent: (x) => x.DimensionalPriceConfiguration, + newPlanMatrixWithAllocation: (x) => x.DimensionalPriceConfiguration, + tieredWithProration: (x) => x.DimensionalPriceConfiguration, + newPlanUnitWithProration: (x) => x.DimensionalPriceConfiguration, + newPlanGroupedAllocation: (x) => x.DimensionalPriceConfiguration, + newPlanBulkWithProration: (x) => x.DimensionalPriceConfiguration, + newPlanGroupedWithProratedMinimum: (x) => x.DimensionalPriceConfiguration, + newPlanGroupedWithMeteredMinimum: (x) => x.DimensionalPriceConfiguration, + groupedWithMinMaxThresholds: (x) => x.DimensionalPriceConfiguration, + newPlanMatrixWithDisplayName: (x) => x.DimensionalPriceConfiguration, + newPlanGroupedTieredPackage: (x) => x.DimensionalPriceConfiguration, + newPlanMaxGroupTieredPackage: (x) => x.DimensionalPriceConfiguration, + newPlanScalableMatrixWithUnitPricing: (x) => x.DimensionalPriceConfiguration, + newPlanScalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, + newPlanCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, + cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, + newPlanMinimumComposite: (x) => x.DimensionalPriceConfiguration, + percent: (x) => x.DimensionalPriceConfiguration, + eventOutput: (x) => x.DimensionalPriceConfiguration + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPercentageDiscount(out var value)) { - /// // `value` is of type `NewPercentageDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) + public string? ExternalPriceID { - value = this.Value as NewPercentageDiscount; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewUsageDiscount(out var value)) { - /// // `value` is of type `NewUsageDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) - { - value = this.Value as NewUsageDiscount; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.ExternalPriceID, + newPlanTiered: (x) => x.ExternalPriceID, + newPlanBulk: (x) => x.ExternalPriceID, + bulkWithFilters: (x) => x.ExternalPriceID, + newPlanPackage: (x) => x.ExternalPriceID, + newPlanMatrix: (x) => x.ExternalPriceID, + newPlanThresholdTotalAmount: (x) => x.ExternalPriceID, + newPlanTieredPackage: (x) => x.ExternalPriceID, + newPlanTieredWithMinimum: (x) => x.ExternalPriceID, + newPlanGroupedTiered: (x) => x.ExternalPriceID, + newPlanTieredPackageWithMinimum: (x) => x.ExternalPriceID, + newPlanPackageWithAllocation: (x) => x.ExternalPriceID, + newPlanUnitWithPercent: (x) => x.ExternalPriceID, + newPlanMatrixWithAllocation: (x) => x.ExternalPriceID, + tieredWithProration: (x) => x.ExternalPriceID, + newPlanUnitWithProration: (x) => x.ExternalPriceID, + newPlanGroupedAllocation: (x) => x.ExternalPriceID, + newPlanBulkWithProration: (x) => x.ExternalPriceID, + newPlanGroupedWithProratedMinimum: (x) => x.ExternalPriceID, + newPlanGroupedWithMeteredMinimum: (x) => x.ExternalPriceID, + groupedWithMinMaxThresholds: (x) => x.ExternalPriceID, + newPlanMatrixWithDisplayName: (x) => x.ExternalPriceID, + newPlanGroupedTieredPackage: (x) => x.ExternalPriceID, + newPlanMaxGroupTieredPackage: (x) => x.ExternalPriceID, + newPlanScalableMatrixWithUnitPricing: (x) => x.ExternalPriceID, + newPlanScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, + newPlanCumulativeGroupedBulk: (x) => x.ExternalPriceID, + cumulativeGroupedAllocation: (x) => x.ExternalPriceID, + newPlanMinimumComposite: (x) => x.ExternalPriceID, + percent: (x) => x.ExternalPriceID, + eventOutput: (x) => x.ExternalPriceID + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewAmountDiscount(out var value)) { - /// // `value` is of type `NewAmountDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) + public double? FixedPriceQuantity { - value = this.Value as NewAmountDiscount; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.FixedPriceQuantity, + newPlanTiered: (x) => x.FixedPriceQuantity, + newPlanBulk: (x) => x.FixedPriceQuantity, + bulkWithFilters: (x) => x.FixedPriceQuantity, + newPlanPackage: (x) => x.FixedPriceQuantity, + newPlanMatrix: (x) => x.FixedPriceQuantity, + newPlanThresholdTotalAmount: (x) => x.FixedPriceQuantity, + newPlanTieredPackage: (x) => x.FixedPriceQuantity, + newPlanTieredWithMinimum: (x) => x.FixedPriceQuantity, + newPlanGroupedTiered: (x) => x.FixedPriceQuantity, + newPlanTieredPackageWithMinimum: (x) => x.FixedPriceQuantity, + newPlanPackageWithAllocation: (x) => x.FixedPriceQuantity, + newPlanUnitWithPercent: (x) => x.FixedPriceQuantity, + newPlanMatrixWithAllocation: (x) => x.FixedPriceQuantity, + tieredWithProration: (x) => x.FixedPriceQuantity, + newPlanUnitWithProration: (x) => x.FixedPriceQuantity, + newPlanGroupedAllocation: (x) => x.FixedPriceQuantity, + newPlanBulkWithProration: (x) => x.FixedPriceQuantity, + newPlanGroupedWithProratedMinimum: (x) => x.FixedPriceQuantity, + newPlanGroupedWithMeteredMinimum: (x) => x.FixedPriceQuantity, + groupedWithMinMaxThresholds: (x) => x.FixedPriceQuantity, + newPlanMatrixWithDisplayName: (x) => x.FixedPriceQuantity, + newPlanGroupedTieredPackage: (x) => x.FixedPriceQuantity, + newPlanMaxGroupTieredPackage: (x) => x.FixedPriceQuantity, + newPlanScalableMatrixWithUnitPricing: (x) => x.FixedPriceQuantity, + newPlanScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, + newPlanCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, + cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, + newPlanMinimumComposite: (x) => x.FixedPriceQuantity, + percent: (x) => x.FixedPriceQuantity, + eventOutput: (x) => x.FixedPriceQuantity + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewMinimum(out var value)) { - /// // `value` is of type `NewMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? value) + public string? InvoiceGroupingKey { - value = this.Value as NewMinimum; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.InvoiceGroupingKey, + newPlanTiered: (x) => x.InvoiceGroupingKey, + newPlanBulk: (x) => x.InvoiceGroupingKey, + bulkWithFilters: (x) => x.InvoiceGroupingKey, + newPlanPackage: (x) => x.InvoiceGroupingKey, + newPlanMatrix: (x) => x.InvoiceGroupingKey, + newPlanThresholdTotalAmount: (x) => x.InvoiceGroupingKey, + newPlanTieredPackage: (x) => x.InvoiceGroupingKey, + newPlanTieredWithMinimum: (x) => x.InvoiceGroupingKey, + newPlanGroupedTiered: (x) => x.InvoiceGroupingKey, + newPlanTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, + newPlanPackageWithAllocation: (x) => x.InvoiceGroupingKey, + newPlanUnitWithPercent: (x) => x.InvoiceGroupingKey, + newPlanMatrixWithAllocation: (x) => x.InvoiceGroupingKey, + tieredWithProration: (x) => x.InvoiceGroupingKey, + newPlanUnitWithProration: (x) => x.InvoiceGroupingKey, + newPlanGroupedAllocation: (x) => x.InvoiceGroupingKey, + newPlanBulkWithProration: (x) => x.InvoiceGroupingKey, + newPlanGroupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, + newPlanGroupedWithMeteredMinimum: (x) => x.InvoiceGroupingKey, + groupedWithMinMaxThresholds: (x) => x.InvoiceGroupingKey, + newPlanMatrixWithDisplayName: (x) => x.InvoiceGroupingKey, + newPlanGroupedTieredPackage: (x) => x.InvoiceGroupingKey, + newPlanMaxGroupTieredPackage: (x) => x.InvoiceGroupingKey, + newPlanScalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, + newPlanScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, + newPlanCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, + cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, + newPlanMinimumComposite: (x) => x.InvoiceGroupingKey, + percent: (x) => x.InvoiceGroupingKey, + eventOutput: (x) => x.InvoiceGroupingKey + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewMaximum(out var value)) { - /// // `value` is of type `NewMaximum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) + public NewBillingCycleConfiguration? InvoicingCycleConfiguration { - value = this.Value as NewMaximum; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.InvoicingCycleConfiguration, + newPlanTiered: (x) => x.InvoicingCycleConfiguration, + newPlanBulk: (x) => x.InvoicingCycleConfiguration, + bulkWithFilters: (x) => x.InvoicingCycleConfiguration, + newPlanPackage: (x) => x.InvoicingCycleConfiguration, + newPlanMatrix: (x) => x.InvoicingCycleConfiguration, + newPlanThresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, + newPlanTieredPackage: (x) => x.InvoicingCycleConfiguration, + newPlanTieredWithMinimum: (x) => x.InvoicingCycleConfiguration, + newPlanGroupedTiered: (x) => x.InvoicingCycleConfiguration, + newPlanTieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, + newPlanPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, + newPlanUnitWithPercent: (x) => x.InvoicingCycleConfiguration, + newPlanMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, + tieredWithProration: (x) => x.InvoicingCycleConfiguration, + newPlanUnitWithProration: (x) => x.InvoicingCycleConfiguration, + newPlanGroupedAllocation: (x) => x.InvoicingCycleConfiguration, + newPlanBulkWithProration: (x) => x.InvoicingCycleConfiguration, + newPlanGroupedWithProratedMinimum: (x) => x.InvoicingCycleConfiguration, + newPlanGroupedWithMeteredMinimum: (x) => x.InvoicingCycleConfiguration, + groupedWithMinMaxThresholds: (x) => x.InvoicingCycleConfiguration, + newPlanMatrixWithDisplayName: (x) => x.InvoicingCycleConfiguration, + newPlanGroupedTieredPackage: (x) => x.InvoicingCycleConfiguration, + newPlanMaxGroupTieredPackage: (x) => x.InvoicingCycleConfiguration, + newPlanScalableMatrixWithUnitPricing: (x) => x.InvoicingCycleConfiguration, + newPlanScalableMatrixWithTieredPricing: (x) => x.InvoicingCycleConfiguration, + newPlanCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, + cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, + newPlanMinimumComposite: (x) => x.InvoicingCycleConfiguration, + percent: (x) => x.InvoicingCycleConfiguration, + eventOutput: (x) => x.InvoicingCycleConfiguration + ); + } } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action newPercentageDiscount, - System::Action newUsageDiscount, - System::Action newAmountDiscount, - System::Action newMinimum, - System::Action newMaximum - ) + public string? ReferenceID { - switch (this.Value) + get { - case NewPercentageDiscount value: - newPercentageDiscount(value); - break; - case NewUsageDiscount value: - newUsageDiscount(value); - break; - case NewAmountDiscount value: - newAmountDiscount(value); - break; - case NewMinimum value: - newMinimum(value); - break; - case NewMaximum value: - newMaximum(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of ReplaceAdjustmentAdjustment" - ); + return Match( + newPlanUnit: (x) => x.ReferenceID, + newPlanTiered: (x) => x.ReferenceID, + newPlanBulk: (x) => x.ReferenceID, + bulkWithFilters: (x) => x.ReferenceID, + newPlanPackage: (x) => x.ReferenceID, + newPlanMatrix: (x) => x.ReferenceID, + newPlanThresholdTotalAmount: (x) => x.ReferenceID, + newPlanTieredPackage: (x) => x.ReferenceID, + newPlanTieredWithMinimum: (x) => x.ReferenceID, + newPlanGroupedTiered: (x) => x.ReferenceID, + newPlanTieredPackageWithMinimum: (x) => x.ReferenceID, + newPlanPackageWithAllocation: (x) => x.ReferenceID, + newPlanUnitWithPercent: (x) => x.ReferenceID, + newPlanMatrixWithAllocation: (x) => x.ReferenceID, + tieredWithProration: (x) => x.ReferenceID, + newPlanUnitWithProration: (x) => x.ReferenceID, + newPlanGroupedAllocation: (x) => x.ReferenceID, + newPlanBulkWithProration: (x) => x.ReferenceID, + newPlanGroupedWithProratedMinimum: (x) => x.ReferenceID, + newPlanGroupedWithMeteredMinimum: (x) => x.ReferenceID, + groupedWithMinMaxThresholds: (x) => x.ReferenceID, + newPlanMatrixWithDisplayName: (x) => x.ReferenceID, + newPlanGroupedTieredPackage: (x) => x.ReferenceID, + newPlanMaxGroupTieredPackage: (x) => x.ReferenceID, + newPlanScalableMatrixWithUnitPricing: (x) => x.ReferenceID, + newPlanScalableMatrixWithTieredPricing: (x) => x.ReferenceID, + newPlanCumulativeGroupedBulk: (x) => x.ReferenceID, + cumulativeGroupedAllocation: (x) => x.ReferenceID, + newPlanMinimumComposite: (x) => x.ReferenceID, + percent: (x) => x.ReferenceID, + eventOutput: (x) => x.ReferenceID + ); } } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func newPercentageDiscount, - System::Func newUsageDiscount, - System::Func newAmountDiscount, - System::Func newMinimum, - System::Func newMaximum - ) + public ReplacePricePrice(NewPlanUnitPrice value, JsonElement? element = null) { - return this.Value switch - { - NewPercentageDiscount value => newPercentageDiscount(value), - NewUsageDiscount value => newUsageDiscount(value), - NewAmountDiscount value => newAmountDiscount(value), - NewMinimum value => newMinimum(value), - NewMaximum value => newMaximum(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplaceAdjustmentAdjustment" - ), - }; + this.Value = value; + this._element = element; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment( - NewPercentageDiscount value - ) => new(value); + public ReplacePricePrice(NewPlanTieredPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment( - NewUsageDiscount value - ) => new(value); + public ReplacePricePrice(NewPlanBulkPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment( - NewAmountDiscount value - ) => new(value); + public ReplacePricePrice(ReplacePricePriceBulkWithFilters value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment( - NewMinimum value - ) => new(value); + public ReplacePricePrice(NewPlanPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment( - NewMaximum value - ) => new(value); + public ReplacePricePrice(NewPlanMatrixPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() + public ReplacePricePrice(NewPlanThresholdTotalAmountPrice value, JsonElement? element = null) { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of ReplaceAdjustmentAdjustment" - ); - } - this.Switch( - (newPercentageDiscount) => newPercentageDiscount.Validate(), - (newUsageDiscount) => newUsageDiscount.Validate(), - (newAmountDiscount) => newAmountDiscount.Validate(), - (newMinimum) => newMinimum.Validate(), - (newMaximum) => newMaximum.Validate() - ); + this.Value = value; + this._element = element; } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment? other - ) + public ReplacePricePrice(NewPlanTieredPackagePrice value, JsonElement? element = null) { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); + this.Value = value; + this._element = element; } - public override int GetHashCode() + public ReplacePricePrice(NewPlanTieredWithMinimumPrice value, JsonElement? element = null) { - return 0; + this.Value = value; + this._element = element; } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} + public ReplacePricePrice(NewPlanGroupedTieredPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } -sealed class ReplaceAdjustmentAdjustmentConverter - : JsonConverter -{ - public override global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options + public ReplacePricePrice( + NewPlanTieredPackageWithMinimumPrice value, + JsonElement? element = null ) { - var element = JsonSerializer.Deserialize(ref reader, options); - string? adjustmentType; - try - { - adjustmentType = element.GetProperty("adjustment_type").GetString(); - } - catch - { - adjustmentType = null; - } + this.Value = value; + this._element = element; + } - switch (adjustmentType) - { - case "percentage_discount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePrice(NewPlanPackageWithAllocationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "usage_discount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePrice(NewPlanUnitWithPercentPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "amount_discount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = JsonSerializer.Deserialize(element, options); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "maximum": - { - try - { - var deserialized = JsonSerializer.Deserialize(element, options); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment( - element - ); - } - } + public ReplacePricePrice(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment value, - JsonSerializerOptions options + public ReplacePricePrice( + ReplacePricePriceTieredWithProration value, + JsonElement? element = null ) { - JsonSerializer.Serialize(writer, value.Json, options); + this.Value = value; + this._element = element; } -} -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePrice, - global::Orb.Models.Beta.ExternalPlanID.ReplacePriceFromRaw - >) -)] -public sealed record class ReplacePrice : JsonModel -{ - /// - /// The id of the price on the plan to replace in the plan. - /// - public required string ReplacesPriceID + public ReplacePricePrice(NewPlanUnitWithProrationPrice value, JsonElement? element = null) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_price_id"); - } - init { this._rawData.Set("replaces_price_id", value); } + this.Value = value; + this._element = element; } - /// - /// The allocation price to add to the plan. - /// - public NewAllocationPrice? AllocationPrice + public ReplacePricePrice(NewPlanGroupedAllocationPrice value, JsonElement? element = null) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("allocation_price"); - } - init { this._rawData.Set("allocation_price", value); } + this.Value = value; + this._element = element; } - /// - /// The phase to replace this price from. - /// - public long? PlanPhaseOrder + public ReplacePricePrice(NewPlanBulkWithProrationPrice value, JsonElement? element = null) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); - } - init { this._rawData.Set("plan_phase_order", value); } + this.Value = value; + this._element = element; } - /// - /// New plan price request body params. - /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice? Price + public ReplacePricePrice( + NewPlanGroupedWithProratedMinimumPrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "price" - ); - } - init { this._rawData.Set("price", value); } + this.Value = value; + this._element = element; } - /// - public override void Validate() + public ReplacePricePrice( + NewPlanGroupedWithMeteredMinimumPrice value, + JsonElement? element = null + ) { - _ = this.ReplacesPriceID; - this.AllocationPrice?.Validate(); - _ = this.PlanPhaseOrder; - this.Price?.Validate(); + this.Value = value; + this._element = element; } - public ReplacePrice() { } + public ReplacePricePrice( + ReplacePricePriceGroupedWithMinMaxThresholds value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - public ReplacePrice(global::Orb.Models.Beta.ExternalPlanID.ReplacePrice replacePrice) - : base(replacePrice) { } + public ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - public ReplacePrice(IReadOnlyDictionary rawData) + public ReplacePricePrice(NewPlanGroupedTieredPackagePrice value, JsonElement? element = null) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePrice(FrozenDictionary rawData) + public ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePrice FromRawUnchecked( - IReadOnlyDictionary rawData + public ReplacePricePrice( + NewPlanScalableMatrixWithUnitPricingPrice value, + JsonElement? element = null ) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this.Value = value; + this._element = element; } - [SetsRequiredMembers] - public ReplacePrice(string replacesPriceID) - : this() + public ReplacePricePrice( + NewPlanScalableMatrixWithTieredPricingPrice value, + JsonElement? element = null + ) { - this.ReplacesPriceID = replacesPriceID; + this.Value = value; + this._element = element; } -} - -class ReplacePriceFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.ReplacePrice.FromRawUnchecked(rawData); -} - -/// -/// New plan price request body params. -/// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceConverter))] -public record class ReplacePricePrice : ModelBase -{ - public object? Value { get; } = null; - JsonElement? _element = null; + public ReplacePricePrice(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - public JsonElement Json + public ReplacePricePrice( + ReplacePricePriceCumulativeGroupedAllocation value, + JsonElement? element = null + ) { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } + this.Value = value; + this._element = element; } - public string ItemID + public ReplacePricePrice(NewPlanMinimumCompositePrice value, JsonElement? element = null) { - get - { - return Match( - newPlanUnit: (x) => x.ItemID, - newPlanTiered: (x) => x.ItemID, - newPlanBulk: (x) => x.ItemID, - bulkWithFilters: (x) => x.ItemID, - newPlanPackage: (x) => x.ItemID, - newPlanMatrix: (x) => x.ItemID, - newPlanThresholdTotalAmount: (x) => x.ItemID, - newPlanTieredPackage: (x) => x.ItemID, - newPlanTieredWithMinimum: (x) => x.ItemID, - newPlanGroupedTiered: (x) => x.ItemID, - newPlanTieredPackageWithMinimum: (x) => x.ItemID, - newPlanPackageWithAllocation: (x) => x.ItemID, - newPlanUnitWithPercent: (x) => x.ItemID, - newPlanMatrixWithAllocation: (x) => x.ItemID, - tieredWithProration: (x) => x.ItemID, - newPlanUnitWithProration: (x) => x.ItemID, - newPlanGroupedAllocation: (x) => x.ItemID, - newPlanBulkWithProration: (x) => x.ItemID, - newPlanGroupedWithProratedMinimum: (x) => x.ItemID, - newPlanGroupedWithMeteredMinimum: (x) => x.ItemID, - groupedWithMinMaxThresholds: (x) => x.ItemID, - newPlanMatrixWithDisplayName: (x) => x.ItemID, - newPlanGroupedTieredPackage: (x) => x.ItemID, - newPlanMaxGroupTieredPackage: (x) => x.ItemID, - newPlanScalableMatrixWithUnitPricing: (x) => x.ItemID, - newPlanScalableMatrixWithTieredPricing: (x) => x.ItemID, - newPlanCumulativeGroupedBulk: (x) => x.ItemID, - cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, - newPlanMinimumComposite: (x) => x.ItemID, - percent: (x) => x.ItemID, - eventOutput: (x) => x.ItemID - ); - } + this.Value = value; + this._element = element; } - public string Name + public ReplacePricePrice(ReplacePricePricePercent value, JsonElement? element = null) { - get - { - return Match( - newPlanUnit: (x) => x.Name, - newPlanTiered: (x) => x.Name, - newPlanBulk: (x) => x.Name, - bulkWithFilters: (x) => x.Name, - newPlanPackage: (x) => x.Name, - newPlanMatrix: (x) => x.Name, - newPlanThresholdTotalAmount: (x) => x.Name, - newPlanTieredPackage: (x) => x.Name, - newPlanTieredWithMinimum: (x) => x.Name, - newPlanGroupedTiered: (x) => x.Name, - newPlanTieredPackageWithMinimum: (x) => x.Name, - newPlanPackageWithAllocation: (x) => x.Name, - newPlanUnitWithPercent: (x) => x.Name, - newPlanMatrixWithAllocation: (x) => x.Name, - tieredWithProration: (x) => x.Name, - newPlanUnitWithProration: (x) => x.Name, - newPlanGroupedAllocation: (x) => x.Name, - newPlanBulkWithProration: (x) => x.Name, - newPlanGroupedWithProratedMinimum: (x) => x.Name, - newPlanGroupedWithMeteredMinimum: (x) => x.Name, - groupedWithMinMaxThresholds: (x) => x.Name, - newPlanMatrixWithDisplayName: (x) => x.Name, - newPlanGroupedTieredPackage: (x) => x.Name, - newPlanMaxGroupTieredPackage: (x) => x.Name, - newPlanScalableMatrixWithUnitPricing: (x) => x.Name, - newPlanScalableMatrixWithTieredPricing: (x) => x.Name, - newPlanCumulativeGroupedBulk: (x) => x.Name, - cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, - newPlanMinimumComposite: (x) => x.Name, - percent: (x) => x.Name, - eventOutput: (x) => x.Name - ); - } + this.Value = value; + this._element = element; } - public string? BillableMetricID + public ReplacePricePrice(ReplacePricePriceEventOutput value, JsonElement? element = null) { - get - { - return Match( - newPlanUnit: (x) => x.BillableMetricID, - newPlanTiered: (x) => x.BillableMetricID, - newPlanBulk: (x) => x.BillableMetricID, - bulkWithFilters: (x) => x.BillableMetricID, - newPlanPackage: (x) => x.BillableMetricID, - newPlanMatrix: (x) => x.BillableMetricID, - newPlanThresholdTotalAmount: (x) => x.BillableMetricID, - newPlanTieredPackage: (x) => x.BillableMetricID, - newPlanTieredWithMinimum: (x) => x.BillableMetricID, - newPlanGroupedTiered: (x) => x.BillableMetricID, - newPlanTieredPackageWithMinimum: (x) => x.BillableMetricID, - newPlanPackageWithAllocation: (x) => x.BillableMetricID, - newPlanUnitWithPercent: (x) => x.BillableMetricID, - newPlanMatrixWithAllocation: (x) => x.BillableMetricID, - tieredWithProration: (x) => x.BillableMetricID, - newPlanUnitWithProration: (x) => x.BillableMetricID, - newPlanGroupedAllocation: (x) => x.BillableMetricID, - newPlanBulkWithProration: (x) => x.BillableMetricID, - newPlanGroupedWithProratedMinimum: (x) => x.BillableMetricID, - newPlanGroupedWithMeteredMinimum: (x) => x.BillableMetricID, - groupedWithMinMaxThresholds: (x) => x.BillableMetricID, - newPlanMatrixWithDisplayName: (x) => x.BillableMetricID, - newPlanGroupedTieredPackage: (x) => x.BillableMetricID, - newPlanMaxGroupTieredPackage: (x) => x.BillableMetricID, - newPlanScalableMatrixWithUnitPricing: (x) => x.BillableMetricID, - newPlanScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, - newPlanCumulativeGroupedBulk: (x) => x.BillableMetricID, - cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, - newPlanMinimumComposite: (x) => x.BillableMetricID, - percent: (x) => x.BillableMetricID, - eventOutput: (x) => x.BillableMetricID - ); - } + this.Value = value; + this._element = element; } - public bool? BilledInAdvance + public ReplacePricePrice(JsonElement element) { - get - { - return Match( - newPlanUnit: (x) => x.BilledInAdvance, - newPlanTiered: (x) => x.BilledInAdvance, - newPlanBulk: (x) => x.BilledInAdvance, - bulkWithFilters: (x) => x.BilledInAdvance, - newPlanPackage: (x) => x.BilledInAdvance, - newPlanMatrix: (x) => x.BilledInAdvance, - newPlanThresholdTotalAmount: (x) => x.BilledInAdvance, - newPlanTieredPackage: (x) => x.BilledInAdvance, - newPlanTieredWithMinimum: (x) => x.BilledInAdvance, - newPlanGroupedTiered: (x) => x.BilledInAdvance, - newPlanTieredPackageWithMinimum: (x) => x.BilledInAdvance, - newPlanPackageWithAllocation: (x) => x.BilledInAdvance, - newPlanUnitWithPercent: (x) => x.BilledInAdvance, - newPlanMatrixWithAllocation: (x) => x.BilledInAdvance, - tieredWithProration: (x) => x.BilledInAdvance, - newPlanUnitWithProration: (x) => x.BilledInAdvance, - newPlanGroupedAllocation: (x) => x.BilledInAdvance, - newPlanBulkWithProration: (x) => x.BilledInAdvance, - newPlanGroupedWithProratedMinimum: (x) => x.BilledInAdvance, - newPlanGroupedWithMeteredMinimum: (x) => x.BilledInAdvance, - groupedWithMinMaxThresholds: (x) => x.BilledInAdvance, - newPlanMatrixWithDisplayName: (x) => x.BilledInAdvance, - newPlanGroupedTieredPackage: (x) => x.BilledInAdvance, - newPlanMaxGroupTieredPackage: (x) => x.BilledInAdvance, - newPlanScalableMatrixWithUnitPricing: (x) => x.BilledInAdvance, - newPlanScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, - newPlanCumulativeGroupedBulk: (x) => x.BilledInAdvance, - cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, - newPlanMinimumComposite: (x) => x.BilledInAdvance, - percent: (x) => x.BilledInAdvance, - eventOutput: (x) => x.BilledInAdvance - ); - } + this._element = element; } - public NewBillingCycleConfiguration? BillingCycleConfiguration + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanUnit(out var value)) { + /// // `value` is of type `NewPlanUnitPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanUnit([NotNullWhen(true)] out NewPlanUnitPrice? value) { - get - { - return Match( - newPlanUnit: (x) => x.BillingCycleConfiguration, - newPlanTiered: (x) => x.BillingCycleConfiguration, - newPlanBulk: (x) => x.BillingCycleConfiguration, - bulkWithFilters: (x) => x.BillingCycleConfiguration, - newPlanPackage: (x) => x.BillingCycleConfiguration, - newPlanMatrix: (x) => x.BillingCycleConfiguration, - newPlanThresholdTotalAmount: (x) => x.BillingCycleConfiguration, - newPlanTieredPackage: (x) => x.BillingCycleConfiguration, - newPlanTieredWithMinimum: (x) => x.BillingCycleConfiguration, - newPlanGroupedTiered: (x) => x.BillingCycleConfiguration, - newPlanTieredPackageWithMinimum: (x) => x.BillingCycleConfiguration, - newPlanPackageWithAllocation: (x) => x.BillingCycleConfiguration, - newPlanUnitWithPercent: (x) => x.BillingCycleConfiguration, - newPlanMatrixWithAllocation: (x) => x.BillingCycleConfiguration, - tieredWithProration: (x) => x.BillingCycleConfiguration, - newPlanUnitWithProration: (x) => x.BillingCycleConfiguration, - newPlanGroupedAllocation: (x) => x.BillingCycleConfiguration, - newPlanBulkWithProration: (x) => x.BillingCycleConfiguration, - newPlanGroupedWithProratedMinimum: (x) => x.BillingCycleConfiguration, - newPlanGroupedWithMeteredMinimum: (x) => x.BillingCycleConfiguration, - groupedWithMinMaxThresholds: (x) => x.BillingCycleConfiguration, - newPlanMatrixWithDisplayName: (x) => x.BillingCycleConfiguration, - newPlanGroupedTieredPackage: (x) => x.BillingCycleConfiguration, - newPlanMaxGroupTieredPackage: (x) => x.BillingCycleConfiguration, - newPlanScalableMatrixWithUnitPricing: (x) => x.BillingCycleConfiguration, - newPlanScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, - newPlanCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, - cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, - newPlanMinimumComposite: (x) => x.BillingCycleConfiguration, - percent: (x) => x.BillingCycleConfiguration, - eventOutput: (x) => x.BillingCycleConfiguration - ); - } + value = this.Value as NewPlanUnitPrice; + return value != null; } - public double? ConversionRate + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanTiered(out var value)) { + /// // `value` is of type `NewPlanTieredPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanTiered([NotNullWhen(true)] out NewPlanTieredPrice? value) { - get - { - return Match( - newPlanUnit: (x) => x.ConversionRate, - newPlanTiered: (x) => x.ConversionRate, - newPlanBulk: (x) => x.ConversionRate, - bulkWithFilters: (x) => x.ConversionRate, - newPlanPackage: (x) => x.ConversionRate, - newPlanMatrix: (x) => x.ConversionRate, - newPlanThresholdTotalAmount: (x) => x.ConversionRate, - newPlanTieredPackage: (x) => x.ConversionRate, - newPlanTieredWithMinimum: (x) => x.ConversionRate, - newPlanGroupedTiered: (x) => x.ConversionRate, - newPlanTieredPackageWithMinimum: (x) => x.ConversionRate, - newPlanPackageWithAllocation: (x) => x.ConversionRate, - newPlanUnitWithPercent: (x) => x.ConversionRate, - newPlanMatrixWithAllocation: (x) => x.ConversionRate, - tieredWithProration: (x) => x.ConversionRate, - newPlanUnitWithProration: (x) => x.ConversionRate, - newPlanGroupedAllocation: (x) => x.ConversionRate, - newPlanBulkWithProration: (x) => x.ConversionRate, - newPlanGroupedWithProratedMinimum: (x) => x.ConversionRate, - newPlanGroupedWithMeteredMinimum: (x) => x.ConversionRate, - groupedWithMinMaxThresholds: (x) => x.ConversionRate, - newPlanMatrixWithDisplayName: (x) => x.ConversionRate, - newPlanGroupedTieredPackage: (x) => x.ConversionRate, - newPlanMaxGroupTieredPackage: (x) => x.ConversionRate, - newPlanScalableMatrixWithUnitPricing: (x) => x.ConversionRate, - newPlanScalableMatrixWithTieredPricing: (x) => x.ConversionRate, - newPlanCumulativeGroupedBulk: (x) => x.ConversionRate, - cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, - newPlanMinimumComposite: (x) => x.ConversionRate, - percent: (x) => x.ConversionRate, - eventOutput: (x) => x.ConversionRate - ); - } + value = this.Value as NewPlanTieredPrice; + return value != null; } - public string? Currency + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanBulk(out var value)) { + /// // `value` is of type `NewPlanBulkPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanBulk([NotNullWhen(true)] out NewPlanBulkPrice? value) { - get - { - return Match( - newPlanUnit: (x) => x.Currency, - newPlanTiered: (x) => x.Currency, - newPlanBulk: (x) => x.Currency, - bulkWithFilters: (x) => x.Currency, - newPlanPackage: (x) => x.Currency, - newPlanMatrix: (x) => x.Currency, - newPlanThresholdTotalAmount: (x) => x.Currency, - newPlanTieredPackage: (x) => x.Currency, - newPlanTieredWithMinimum: (x) => x.Currency, - newPlanGroupedTiered: (x) => x.Currency, - newPlanTieredPackageWithMinimum: (x) => x.Currency, - newPlanPackageWithAllocation: (x) => x.Currency, - newPlanUnitWithPercent: (x) => x.Currency, - newPlanMatrixWithAllocation: (x) => x.Currency, - tieredWithProration: (x) => x.Currency, - newPlanUnitWithProration: (x) => x.Currency, - newPlanGroupedAllocation: (x) => x.Currency, - newPlanBulkWithProration: (x) => x.Currency, - newPlanGroupedWithProratedMinimum: (x) => x.Currency, - newPlanGroupedWithMeteredMinimum: (x) => x.Currency, - groupedWithMinMaxThresholds: (x) => x.Currency, - newPlanMatrixWithDisplayName: (x) => x.Currency, - newPlanGroupedTieredPackage: (x) => x.Currency, - newPlanMaxGroupTieredPackage: (x) => x.Currency, - newPlanScalableMatrixWithUnitPricing: (x) => x.Currency, - newPlanScalableMatrixWithTieredPricing: (x) => x.Currency, - newPlanCumulativeGroupedBulk: (x) => x.Currency, - cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, - newPlanMinimumComposite: (x) => x.Currency, - percent: (x) => x.Currency, - eventOutput: (x) => x.Currency - ); - } + value = this.Value as NewPlanBulkPrice; + return value != null; } - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBulkWithFilters(out var value)) { + /// // `value` is of type `ReplacePricePriceBulkWithFilters` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulkWithFilters( + [NotNullWhen(true)] out ReplacePricePriceBulkWithFilters? value + ) { - get - { - return Match( - newPlanUnit: (x) => x.DimensionalPriceConfiguration, - newPlanTiered: (x) => x.DimensionalPriceConfiguration, - newPlanBulk: (x) => x.DimensionalPriceConfiguration, - bulkWithFilters: (x) => x.DimensionalPriceConfiguration, - newPlanPackage: (x) => x.DimensionalPriceConfiguration, - newPlanMatrix: (x) => x.DimensionalPriceConfiguration, - newPlanThresholdTotalAmount: (x) => x.DimensionalPriceConfiguration, - newPlanTieredPackage: (x) => x.DimensionalPriceConfiguration, - newPlanTieredWithMinimum: (x) => x.DimensionalPriceConfiguration, - newPlanGroupedTiered: (x) => x.DimensionalPriceConfiguration, - newPlanTieredPackageWithMinimum: (x) => x.DimensionalPriceConfiguration, - newPlanPackageWithAllocation: (x) => x.DimensionalPriceConfiguration, - newPlanUnitWithPercent: (x) => x.DimensionalPriceConfiguration, - newPlanMatrixWithAllocation: (x) => x.DimensionalPriceConfiguration, - tieredWithProration: (x) => x.DimensionalPriceConfiguration, - newPlanUnitWithProration: (x) => x.DimensionalPriceConfiguration, - newPlanGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - newPlanBulkWithProration: (x) => x.DimensionalPriceConfiguration, - newPlanGroupedWithProratedMinimum: (x) => x.DimensionalPriceConfiguration, - newPlanGroupedWithMeteredMinimum: (x) => x.DimensionalPriceConfiguration, - groupedWithMinMaxThresholds: (x) => x.DimensionalPriceConfiguration, - newPlanMatrixWithDisplayName: (x) => x.DimensionalPriceConfiguration, - newPlanGroupedTieredPackage: (x) => x.DimensionalPriceConfiguration, - newPlanMaxGroupTieredPackage: (x) => x.DimensionalPriceConfiguration, - newPlanScalableMatrixWithUnitPricing: (x) => x.DimensionalPriceConfiguration, - newPlanScalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, - newPlanCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, - cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, - newPlanMinimumComposite: (x) => x.DimensionalPriceConfiguration, - percent: (x) => x.DimensionalPriceConfiguration, - eventOutput: (x) => x.DimensionalPriceConfiguration - ); - } + value = this.Value as ReplacePricePriceBulkWithFilters; + return value != null; } - public string? ExternalPriceID + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanPackage(out var value)) { + /// // `value` is of type `NewPlanPackagePrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanPackage([NotNullWhen(true)] out NewPlanPackagePrice? value) { - get - { - return Match( - newPlanUnit: (x) => x.ExternalPriceID, - newPlanTiered: (x) => x.ExternalPriceID, - newPlanBulk: (x) => x.ExternalPriceID, - bulkWithFilters: (x) => x.ExternalPriceID, - newPlanPackage: (x) => x.ExternalPriceID, - newPlanMatrix: (x) => x.ExternalPriceID, - newPlanThresholdTotalAmount: (x) => x.ExternalPriceID, - newPlanTieredPackage: (x) => x.ExternalPriceID, - newPlanTieredWithMinimum: (x) => x.ExternalPriceID, - newPlanGroupedTiered: (x) => x.ExternalPriceID, - newPlanTieredPackageWithMinimum: (x) => x.ExternalPriceID, - newPlanPackageWithAllocation: (x) => x.ExternalPriceID, - newPlanUnitWithPercent: (x) => x.ExternalPriceID, - newPlanMatrixWithAllocation: (x) => x.ExternalPriceID, - tieredWithProration: (x) => x.ExternalPriceID, - newPlanUnitWithProration: (x) => x.ExternalPriceID, - newPlanGroupedAllocation: (x) => x.ExternalPriceID, - newPlanBulkWithProration: (x) => x.ExternalPriceID, - newPlanGroupedWithProratedMinimum: (x) => x.ExternalPriceID, - newPlanGroupedWithMeteredMinimum: (x) => x.ExternalPriceID, - groupedWithMinMaxThresholds: (x) => x.ExternalPriceID, - newPlanMatrixWithDisplayName: (x) => x.ExternalPriceID, - newPlanGroupedTieredPackage: (x) => x.ExternalPriceID, - newPlanMaxGroupTieredPackage: (x) => x.ExternalPriceID, - newPlanScalableMatrixWithUnitPricing: (x) => x.ExternalPriceID, - newPlanScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, - newPlanCumulativeGroupedBulk: (x) => x.ExternalPriceID, - cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, - newPlanMinimumComposite: (x) => x.ExternalPriceID, - percent: (x) => x.ExternalPriceID, - eventOutput: (x) => x.ExternalPriceID - ); - } + value = this.Value as NewPlanPackagePrice; + return value != null; } - public double? FixedPriceQuantity + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanMatrix(out var value)) { + /// // `value` is of type `NewPlanMatrixPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanMatrix([NotNullWhen(true)] out NewPlanMatrixPrice? value) { - get - { - return Match( - newPlanUnit: (x) => x.FixedPriceQuantity, - newPlanTiered: (x) => x.FixedPriceQuantity, - newPlanBulk: (x) => x.FixedPriceQuantity, - bulkWithFilters: (x) => x.FixedPriceQuantity, - newPlanPackage: (x) => x.FixedPriceQuantity, - newPlanMatrix: (x) => x.FixedPriceQuantity, - newPlanThresholdTotalAmount: (x) => x.FixedPriceQuantity, - newPlanTieredPackage: (x) => x.FixedPriceQuantity, - newPlanTieredWithMinimum: (x) => x.FixedPriceQuantity, - newPlanGroupedTiered: (x) => x.FixedPriceQuantity, - newPlanTieredPackageWithMinimum: (x) => x.FixedPriceQuantity, - newPlanPackageWithAllocation: (x) => x.FixedPriceQuantity, - newPlanUnitWithPercent: (x) => x.FixedPriceQuantity, - newPlanMatrixWithAllocation: (x) => x.FixedPriceQuantity, - tieredWithProration: (x) => x.FixedPriceQuantity, - newPlanUnitWithProration: (x) => x.FixedPriceQuantity, - newPlanGroupedAllocation: (x) => x.FixedPriceQuantity, - newPlanBulkWithProration: (x) => x.FixedPriceQuantity, - newPlanGroupedWithProratedMinimum: (x) => x.FixedPriceQuantity, - newPlanGroupedWithMeteredMinimum: (x) => x.FixedPriceQuantity, - groupedWithMinMaxThresholds: (x) => x.FixedPriceQuantity, - newPlanMatrixWithDisplayName: (x) => x.FixedPriceQuantity, - newPlanGroupedTieredPackage: (x) => x.FixedPriceQuantity, - newPlanMaxGroupTieredPackage: (x) => x.FixedPriceQuantity, - newPlanScalableMatrixWithUnitPricing: (x) => x.FixedPriceQuantity, - newPlanScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, - newPlanCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, - cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, - newPlanMinimumComposite: (x) => x.FixedPriceQuantity, - percent: (x) => x.FixedPriceQuantity, - eventOutput: (x) => x.FixedPriceQuantity - ); - } + value = this.Value as NewPlanMatrixPrice; + return value != null; } - public string? InvoiceGroupingKey + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanThresholdTotalAmount(out var value)) { + /// // `value` is of type `NewPlanThresholdTotalAmountPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanThresholdTotalAmount( + [NotNullWhen(true)] out NewPlanThresholdTotalAmountPrice? value + ) { - get - { - return Match( - newPlanUnit: (x) => x.InvoiceGroupingKey, - newPlanTiered: (x) => x.InvoiceGroupingKey, - newPlanBulk: (x) => x.InvoiceGroupingKey, - bulkWithFilters: (x) => x.InvoiceGroupingKey, - newPlanPackage: (x) => x.InvoiceGroupingKey, - newPlanMatrix: (x) => x.InvoiceGroupingKey, - newPlanThresholdTotalAmount: (x) => x.InvoiceGroupingKey, - newPlanTieredPackage: (x) => x.InvoiceGroupingKey, - newPlanTieredWithMinimum: (x) => x.InvoiceGroupingKey, - newPlanGroupedTiered: (x) => x.InvoiceGroupingKey, - newPlanTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, - newPlanPackageWithAllocation: (x) => x.InvoiceGroupingKey, - newPlanUnitWithPercent: (x) => x.InvoiceGroupingKey, - newPlanMatrixWithAllocation: (x) => x.InvoiceGroupingKey, - tieredWithProration: (x) => x.InvoiceGroupingKey, - newPlanUnitWithProration: (x) => x.InvoiceGroupingKey, - newPlanGroupedAllocation: (x) => x.InvoiceGroupingKey, - newPlanBulkWithProration: (x) => x.InvoiceGroupingKey, - newPlanGroupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, - newPlanGroupedWithMeteredMinimum: (x) => x.InvoiceGroupingKey, - groupedWithMinMaxThresholds: (x) => x.InvoiceGroupingKey, - newPlanMatrixWithDisplayName: (x) => x.InvoiceGroupingKey, - newPlanGroupedTieredPackage: (x) => x.InvoiceGroupingKey, - newPlanMaxGroupTieredPackage: (x) => x.InvoiceGroupingKey, - newPlanScalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, - newPlanScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, - newPlanCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, - cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, - newPlanMinimumComposite: (x) => x.InvoiceGroupingKey, - percent: (x) => x.InvoiceGroupingKey, - eventOutput: (x) => x.InvoiceGroupingKey - ); - } + value = this.Value as NewPlanThresholdTotalAmountPrice; + return value != null; } - public NewBillingCycleConfiguration? InvoicingCycleConfiguration - { - get - { - return Match( - newPlanUnit: (x) => x.InvoicingCycleConfiguration, - newPlanTiered: (x) => x.InvoicingCycleConfiguration, - newPlanBulk: (x) => x.InvoicingCycleConfiguration, - bulkWithFilters: (x) => x.InvoicingCycleConfiguration, - newPlanPackage: (x) => x.InvoicingCycleConfiguration, - newPlanMatrix: (x) => x.InvoicingCycleConfiguration, - newPlanThresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, - newPlanTieredPackage: (x) => x.InvoicingCycleConfiguration, - newPlanTieredWithMinimum: (x) => x.InvoicingCycleConfiguration, - newPlanGroupedTiered: (x) => x.InvoicingCycleConfiguration, - newPlanTieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, - newPlanPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, - newPlanUnitWithPercent: (x) => x.InvoicingCycleConfiguration, - newPlanMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, - tieredWithProration: (x) => x.InvoicingCycleConfiguration, - newPlanUnitWithProration: (x) => x.InvoicingCycleConfiguration, - newPlanGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - newPlanBulkWithProration: (x) => x.InvoicingCycleConfiguration, - newPlanGroupedWithProratedMinimum: (x) => x.InvoicingCycleConfiguration, - newPlanGroupedWithMeteredMinimum: (x) => x.InvoicingCycleConfiguration, - groupedWithMinMaxThresholds: (x) => x.InvoicingCycleConfiguration, - newPlanMatrixWithDisplayName: (x) => x.InvoicingCycleConfiguration, - newPlanGroupedTieredPackage: (x) => x.InvoicingCycleConfiguration, - newPlanMaxGroupTieredPackage: (x) => x.InvoicingCycleConfiguration, - newPlanScalableMatrixWithUnitPricing: (x) => x.InvoicingCycleConfiguration, - newPlanScalableMatrixWithTieredPricing: (x) => x.InvoicingCycleConfiguration, - newPlanCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, - cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, - newPlanMinimumComposite: (x) => x.InvoicingCycleConfiguration, - percent: (x) => x.InvoicingCycleConfiguration, - eventOutput: (x) => x.InvoicingCycleConfiguration - ); - } - } - - public string? ReferenceID - { - get - { - return Match( - newPlanUnit: (x) => x.ReferenceID, - newPlanTiered: (x) => x.ReferenceID, - newPlanBulk: (x) => x.ReferenceID, - bulkWithFilters: (x) => x.ReferenceID, - newPlanPackage: (x) => x.ReferenceID, - newPlanMatrix: (x) => x.ReferenceID, - newPlanThresholdTotalAmount: (x) => x.ReferenceID, - newPlanTieredPackage: (x) => x.ReferenceID, - newPlanTieredWithMinimum: (x) => x.ReferenceID, - newPlanGroupedTiered: (x) => x.ReferenceID, - newPlanTieredPackageWithMinimum: (x) => x.ReferenceID, - newPlanPackageWithAllocation: (x) => x.ReferenceID, - newPlanUnitWithPercent: (x) => x.ReferenceID, - newPlanMatrixWithAllocation: (x) => x.ReferenceID, - tieredWithProration: (x) => x.ReferenceID, - newPlanUnitWithProration: (x) => x.ReferenceID, - newPlanGroupedAllocation: (x) => x.ReferenceID, - newPlanBulkWithProration: (x) => x.ReferenceID, - newPlanGroupedWithProratedMinimum: (x) => x.ReferenceID, - newPlanGroupedWithMeteredMinimum: (x) => x.ReferenceID, - groupedWithMinMaxThresholds: (x) => x.ReferenceID, - newPlanMatrixWithDisplayName: (x) => x.ReferenceID, - newPlanGroupedTieredPackage: (x) => x.ReferenceID, - newPlanMaxGroupTieredPackage: (x) => x.ReferenceID, - newPlanScalableMatrixWithUnitPricing: (x) => x.ReferenceID, - newPlanScalableMatrixWithTieredPricing: (x) => x.ReferenceID, - newPlanCumulativeGroupedBulk: (x) => x.ReferenceID, - cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, - newPlanMinimumComposite: (x) => x.ReferenceID, - percent: (x) => x.ReferenceID, - eventOutput: (x) => x.ReferenceID - ); - } - } - - public ReplacePricePrice(NewPlanUnitPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanTieredPrice value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanTieredPackage(out var value)) { + /// // `value` is of type `NewPlanTieredPackagePrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanTieredPackage( + [NotNullWhen(true)] out NewPlanTieredPackagePrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewPlanTieredPackagePrice; + return value != null; } - public ReplacePricePrice(NewPlanBulkPrice value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanTieredWithMinimum(out var value)) { + /// // `value` is of type `NewPlanTieredWithMinimumPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanTieredWithMinimum( + [NotNullWhen(true)] out NewPlanTieredWithMinimumPrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewPlanTieredWithMinimumPrice; + return value != null; } - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value, - JsonElement? element = null + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanGroupedTiered(out var value)) { + /// // `value` is of type `NewPlanGroupedTieredPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanGroupedTiered( + [NotNullWhen(true)] out NewPlanGroupedTieredPrice? value ) { - this.Value = value; - this._element = element; + value = this.Value as NewPlanGroupedTieredPrice; + return value != null; } - public ReplacePricePrice(NewPlanPackagePrice value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanTieredPackageWithMinimum(out var value)) { + /// // `value` is of type `NewPlanTieredPackageWithMinimumPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanTieredPackageWithMinimum( + [NotNullWhen(true)] out NewPlanTieredPackageWithMinimumPrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewPlanTieredPackageWithMinimumPrice; + return value != null; } - public ReplacePricePrice(NewPlanMatrixPrice value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanPackageWithAllocation(out var value)) { + /// // `value` is of type `NewPlanPackageWithAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanPackageWithAllocation( + [NotNullWhen(true)] out NewPlanPackageWithAllocationPrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewPlanPackageWithAllocationPrice; + return value != null; } - public ReplacePricePrice(NewPlanThresholdTotalAmountPrice value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanUnitWithPercent(out var value)) { + /// // `value` is of type `NewPlanUnitWithPercentPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanUnitWithPercent( + [NotNullWhen(true)] out NewPlanUnitWithPercentPrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewPlanUnitWithPercentPrice; + return value != null; } - public ReplacePricePrice(NewPlanTieredPackagePrice value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanMatrixWithAllocation(out var value)) { + /// // `value` is of type `NewPlanMatrixWithAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanMatrixWithAllocation( + [NotNullWhen(true)] out NewPlanMatrixWithAllocationPrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewPlanMatrixWithAllocationPrice; + return value != null; } - public ReplacePricePrice(NewPlanTieredWithMinimumPrice value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTieredWithProration(out var value)) { + /// // `value` is of type `ReplacePricePriceTieredWithProration` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredWithProration( + [NotNullWhen(true)] out ReplacePricePriceTieredWithProration? value + ) { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanGroupedTieredPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewPlanTieredPackageWithMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanPackageWithAllocationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanUnitWithPercentPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanUnitWithProrationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanGroupedAllocationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanBulkWithProrationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewPlanGroupedWithProratedMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewPlanGroupedWithMeteredMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanGroupedTieredPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewPlanScalableMatrixWithUnitPricingPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewPlanScalableMatrixWithTieredPricingPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewPlanMinimumCompositePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(JsonElement element) - { - this._element = element; + value = this.Value as ReplacePricePriceTieredWithProration; + return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanUnit(out var value)) { - /// // `value` is of type `NewPlanUnitPrice` + /// if (instance.TryPickNewPlanUnitWithProration(out var value)) { + /// // `value` is of type `NewPlanUnitWithProrationPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanUnit([NotNullWhen(true)] out NewPlanUnitPrice? value) + public bool TryPickNewPlanUnitWithProration( + [NotNullWhen(true)] out NewPlanUnitWithProrationPrice? value + ) { - value = this.Value as NewPlanUnitPrice; + value = this.Value as NewPlanUnitWithProrationPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanTiered(out var value)) { - /// // `value` is of type `NewPlanTieredPrice` + /// if (instance.TryPickNewPlanGroupedAllocation(out var value)) { + /// // `value` is of type `NewPlanGroupedAllocationPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanTiered([NotNullWhen(true)] out NewPlanTieredPrice? value) + public bool TryPickNewPlanGroupedAllocation( + [NotNullWhen(true)] out NewPlanGroupedAllocationPrice? value + ) { - value = this.Value as NewPlanTieredPrice; + value = this.Value as NewPlanGroupedAllocationPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanBulk(out var value)) { - /// // `value` is of type `NewPlanBulkPrice` + /// if (instance.TryPickNewPlanBulkWithProration(out var value)) { + /// // `value` is of type `NewPlanBulkWithProrationPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanBulk([NotNullWhen(true)] out NewPlanBulkPrice? value) + public bool TryPickNewPlanBulkWithProration( + [NotNullWhen(true)] out NewPlanBulkWithProrationPrice? value + ) { - value = this.Value as NewPlanBulkPrice; + value = this.Value as NewPlanBulkWithProrationPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickBulkWithFilters(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters` + /// if (instance.TryPickNewPlanGroupedWithProratedMinimum(out var value)) { + /// // `value` is of type `NewPlanGroupedWithProratedMinimumPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickBulkWithFilters( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters? value + public bool TryPickNewPlanGroupedWithProratedMinimum( + [NotNullWhen(true)] out NewPlanGroupedWithProratedMinimumPrice? value ) { - value = - this.Value as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters; + value = this.Value as NewPlanGroupedWithProratedMinimumPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanPackage(out var value)) { - /// // `value` is of type `NewPlanPackagePrice` + /// if (instance.TryPickNewPlanGroupedWithMeteredMinimum(out var value)) { + /// // `value` is of type `NewPlanGroupedWithMeteredMinimumPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanPackage([NotNullWhen(true)] out NewPlanPackagePrice? value) + public bool TryPickNewPlanGroupedWithMeteredMinimum( + [NotNullWhen(true)] out NewPlanGroupedWithMeteredMinimumPrice? value + ) { - value = this.Value as NewPlanPackagePrice; + value = this.Value as NewPlanGroupedWithMeteredMinimumPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanMatrix(out var value)) { - /// // `value` is of type `NewPlanMatrixPrice` + /// if (instance.TryPickGroupedWithMinMaxThresholds(out var value)) { + /// // `value` is of type `ReplacePricePriceGroupedWithMinMaxThresholds` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanMatrix([NotNullWhen(true)] out NewPlanMatrixPrice? value) + public bool TryPickGroupedWithMinMaxThresholds( + [NotNullWhen(true)] out ReplacePricePriceGroupedWithMinMaxThresholds? value + ) { - value = this.Value as NewPlanMatrixPrice; + value = this.Value as ReplacePricePriceGroupedWithMinMaxThresholds; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanThresholdTotalAmount(out var value)) { - /// // `value` is of type `NewPlanThresholdTotalAmountPrice` + /// if (instance.TryPickNewPlanMatrixWithDisplayName(out var value)) { + /// // `value` is of type `NewPlanMatrixWithDisplayNamePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanThresholdTotalAmount( - [NotNullWhen(true)] out NewPlanThresholdTotalAmountPrice? value + public bool TryPickNewPlanMatrixWithDisplayName( + [NotNullWhen(true)] out NewPlanMatrixWithDisplayNamePrice? value ) { - value = this.Value as NewPlanThresholdTotalAmountPrice; + value = this.Value as NewPlanMatrixWithDisplayNamePrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanTieredPackage(out var value)) { - /// // `value` is of type `NewPlanTieredPackagePrice` + /// if (instance.TryPickNewPlanGroupedTieredPackage(out var value)) { + /// // `value` is of type `NewPlanGroupedTieredPackagePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanTieredPackage( - [NotNullWhen(true)] out NewPlanTieredPackagePrice? value + public bool TryPickNewPlanGroupedTieredPackage( + [NotNullWhen(true)] out NewPlanGroupedTieredPackagePrice? value ) { - value = this.Value as NewPlanTieredPackagePrice; + value = this.Value as NewPlanGroupedTieredPackagePrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanTieredWithMinimum(out var value)) { - /// // `value` is of type `NewPlanTieredWithMinimumPrice` + /// if (instance.TryPickNewPlanMaxGroupTieredPackage(out var value)) { + /// // `value` is of type `NewPlanMaxGroupTieredPackagePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanTieredWithMinimum( - [NotNullWhen(true)] out NewPlanTieredWithMinimumPrice? value + public bool TryPickNewPlanMaxGroupTieredPackage( + [NotNullWhen(true)] out NewPlanMaxGroupTieredPackagePrice? value ) { - value = this.Value as NewPlanTieredWithMinimumPrice; + value = this.Value as NewPlanMaxGroupTieredPackagePrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanGroupedTiered(out var value)) { - /// // `value` is of type `NewPlanGroupedTieredPrice` + /// if (instance.TryPickNewPlanScalableMatrixWithUnitPricing(out var value)) { + /// // `value` is of type `NewPlanScalableMatrixWithUnitPricingPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanGroupedTiered( - [NotNullWhen(true)] out NewPlanGroupedTieredPrice? value + public bool TryPickNewPlanScalableMatrixWithUnitPricing( + [NotNullWhen(true)] out NewPlanScalableMatrixWithUnitPricingPrice? value ) { - value = this.Value as NewPlanGroupedTieredPrice; + value = this.Value as NewPlanScalableMatrixWithUnitPricingPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanTieredPackageWithMinimum(out var value)) { - /// // `value` is of type `NewPlanTieredPackageWithMinimumPrice` + /// if (instance.TryPickNewPlanScalableMatrixWithTieredPricing(out var value)) { + /// // `value` is of type `NewPlanScalableMatrixWithTieredPricingPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanTieredPackageWithMinimum( - [NotNullWhen(true)] out NewPlanTieredPackageWithMinimumPrice? value + public bool TryPickNewPlanScalableMatrixWithTieredPricing( + [NotNullWhen(true)] out NewPlanScalableMatrixWithTieredPricingPrice? value ) { - value = this.Value as NewPlanTieredPackageWithMinimumPrice; + value = this.Value as NewPlanScalableMatrixWithTieredPricingPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanPackageWithAllocation(out var value)) { - /// // `value` is of type `NewPlanPackageWithAllocationPrice` + /// if (instance.TryPickNewPlanCumulativeGroupedBulk(out var value)) { + /// // `value` is of type `NewPlanCumulativeGroupedBulkPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanPackageWithAllocation( - [NotNullWhen(true)] out NewPlanPackageWithAllocationPrice? value + public bool TryPickNewPlanCumulativeGroupedBulk( + [NotNullWhen(true)] out NewPlanCumulativeGroupedBulkPrice? value ) { - value = this.Value as NewPlanPackageWithAllocationPrice; + value = this.Value as NewPlanCumulativeGroupedBulkPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanUnitWithPercent(out var value)) { - /// // `value` is of type `NewPlanUnitWithPercentPrice` + /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { + /// // `value` is of type `ReplacePricePriceCumulativeGroupedAllocation` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanUnitWithPercent( - [NotNullWhen(true)] out NewPlanUnitWithPercentPrice? value + public bool TryPickCumulativeGroupedAllocation( + [NotNullWhen(true)] out ReplacePricePriceCumulativeGroupedAllocation? value ) { - value = this.Value as NewPlanUnitWithPercentPrice; + value = this.Value as ReplacePricePriceCumulativeGroupedAllocation; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanMatrixWithAllocation(out var value)) { - /// // `value` is of type `NewPlanMatrixWithAllocationPrice` + /// if (instance.TryPickNewPlanMinimumComposite(out var value)) { + /// // `value` is of type `NewPlanMinimumCompositePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanMatrixWithAllocation( - [NotNullWhen(true)] out NewPlanMatrixWithAllocationPrice? value + public bool TryPickNewPlanMinimumComposite( + [NotNullWhen(true)] out NewPlanMinimumCompositePrice? value ) { - value = this.Value as NewPlanMatrixWithAllocationPrice; + value = this.Value as NewPlanMinimumCompositePrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickTieredWithProration(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration` + /// if (instance.TryPickPercent(out var value)) { + /// // `value` is of type `ReplacePricePricePercent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTieredWithProration( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration? value - ) + public bool TryPickPercent([NotNullWhen(true)] out ReplacePricePricePercent? value) { - value = - this.Value - as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration; + value = this.Value as ReplacePricePricePercent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewPlanUnitWithProration(out var value)) { - /// // `value` is of type `NewPlanUnitWithProrationPrice` + /// if (instance.TryPickEventOutput(out var value)) { + /// // `value` is of type `ReplacePricePriceEventOutput` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanUnitWithProration( - [NotNullWhen(true)] out NewPlanUnitWithProrationPrice? value - ) + public bool TryPickEventOutput([NotNullWhen(true)] out ReplacePricePriceEventOutput? value) { - value = this.Value as NewPlanUnitWithProrationPrice; + value = this.Value as ReplacePricePriceEventOutput; return value != null; } /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Consider using or if you need to handle every variant. + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// /// /// /// - /// if (instance.TryPickNewPlanGroupedAllocation(out var value)) { - /// // `value` is of type `NewPlanGroupedAllocationPrice` - /// Console.WriteLine(value); - /// } + /// instance.Switch( + /// (NewPlanUnitPrice value) => {...}, + /// (NewPlanTieredPrice value) => {...}, + /// (NewPlanBulkPrice value) => {...}, + /// (ReplacePricePriceBulkWithFilters value) => {...}, + /// (NewPlanPackagePrice value) => {...}, + /// (NewPlanMatrixPrice value) => {...}, + /// (NewPlanThresholdTotalAmountPrice value) => {...}, + /// (NewPlanTieredPackagePrice value) => {...}, + /// (NewPlanTieredWithMinimumPrice value) => {...}, + /// (NewPlanGroupedTieredPrice value) => {...}, + /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, + /// (NewPlanPackageWithAllocationPrice value) => {...}, + /// (NewPlanUnitWithPercentPrice value) => {...}, + /// (NewPlanMatrixWithAllocationPrice value) => {...}, + /// (ReplacePricePriceTieredWithProration value) => {...}, + /// (NewPlanUnitWithProrationPrice value) => {...}, + /// (NewPlanGroupedAllocationPrice value) => {...}, + /// (NewPlanBulkWithProrationPrice value) => {...}, + /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, + /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, + /// (ReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, + /// (NewPlanGroupedTieredPackagePrice value) => {...}, + /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, + /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, + /// (ReplacePricePriceCumulativeGroupedAllocation value) => {...}, + /// (NewPlanMinimumCompositePrice value) => {...}, + /// (ReplacePricePricePercent value) => {...}, + /// (ReplacePricePriceEventOutput value) => {...} + /// ); /// /// /// - public bool TryPickNewPlanGroupedAllocation( - [NotNullWhen(true)] out NewPlanGroupedAllocationPrice? value + public void Switch( + System::Action newPlanUnit, + System::Action newPlanTiered, + System::Action newPlanBulk, + System::Action bulkWithFilters, + System::Action newPlanPackage, + System::Action newPlanMatrix, + System::Action newPlanThresholdTotalAmount, + System::Action newPlanTieredPackage, + System::Action newPlanTieredWithMinimum, + System::Action newPlanGroupedTiered, + System::Action newPlanTieredPackageWithMinimum, + System::Action newPlanPackageWithAllocation, + System::Action newPlanUnitWithPercent, + System::Action newPlanMatrixWithAllocation, + System::Action tieredWithProration, + System::Action newPlanUnitWithProration, + System::Action newPlanGroupedAllocation, + System::Action newPlanBulkWithProration, + System::Action newPlanGroupedWithProratedMinimum, + System::Action newPlanGroupedWithMeteredMinimum, + System::Action groupedWithMinMaxThresholds, + System::Action newPlanMatrixWithDisplayName, + System::Action newPlanGroupedTieredPackage, + System::Action newPlanMaxGroupTieredPackage, + System::Action newPlanScalableMatrixWithUnitPricing, + System::Action newPlanScalableMatrixWithTieredPricing, + System::Action newPlanCumulativeGroupedBulk, + System::Action cumulativeGroupedAllocation, + System::Action newPlanMinimumComposite, + System::Action percent, + System::Action eventOutput ) { - value = this.Value as NewPlanGroupedAllocationPrice; - return value != null; + switch (this.Value) + { + case NewPlanUnitPrice value: + newPlanUnit(value); + break; + case NewPlanTieredPrice value: + newPlanTiered(value); + break; + case NewPlanBulkPrice value: + newPlanBulk(value); + break; + case ReplacePricePriceBulkWithFilters value: + bulkWithFilters(value); + break; + case NewPlanPackagePrice value: + newPlanPackage(value); + break; + case NewPlanMatrixPrice value: + newPlanMatrix(value); + break; + case NewPlanThresholdTotalAmountPrice value: + newPlanThresholdTotalAmount(value); + break; + case NewPlanTieredPackagePrice value: + newPlanTieredPackage(value); + break; + case NewPlanTieredWithMinimumPrice value: + newPlanTieredWithMinimum(value); + break; + case NewPlanGroupedTieredPrice value: + newPlanGroupedTiered(value); + break; + case NewPlanTieredPackageWithMinimumPrice value: + newPlanTieredPackageWithMinimum(value); + break; + case NewPlanPackageWithAllocationPrice value: + newPlanPackageWithAllocation(value); + break; + case NewPlanUnitWithPercentPrice value: + newPlanUnitWithPercent(value); + break; + case NewPlanMatrixWithAllocationPrice value: + newPlanMatrixWithAllocation(value); + break; + case ReplacePricePriceTieredWithProration value: + tieredWithProration(value); + break; + case NewPlanUnitWithProrationPrice value: + newPlanUnitWithProration(value); + break; + case NewPlanGroupedAllocationPrice value: + newPlanGroupedAllocation(value); + break; + case NewPlanBulkWithProrationPrice value: + newPlanBulkWithProration(value); + break; + case NewPlanGroupedWithProratedMinimumPrice value: + newPlanGroupedWithProratedMinimum(value); + break; + case NewPlanGroupedWithMeteredMinimumPrice value: + newPlanGroupedWithMeteredMinimum(value); + break; + case ReplacePricePriceGroupedWithMinMaxThresholds value: + groupedWithMinMaxThresholds(value); + break; + case NewPlanMatrixWithDisplayNamePrice value: + newPlanMatrixWithDisplayName(value); + break; + case NewPlanGroupedTieredPackagePrice value: + newPlanGroupedTieredPackage(value); + break; + case NewPlanMaxGroupTieredPackagePrice value: + newPlanMaxGroupTieredPackage(value); + break; + case NewPlanScalableMatrixWithUnitPricingPrice value: + newPlanScalableMatrixWithUnitPricing(value); + break; + case NewPlanScalableMatrixWithTieredPricingPrice value: + newPlanScalableMatrixWithTieredPricing(value); + break; + case NewPlanCumulativeGroupedBulkPrice value: + newPlanCumulativeGroupedBulk(value); + break; + case ReplacePricePriceCumulativeGroupedAllocation value: + cumulativeGroupedAllocation(value); + break; + case NewPlanMinimumCompositePrice value: + newPlanMinimumComposite(value); + break; + case ReplacePricePricePercent value: + percent(value); + break; + case ReplacePricePriceEventOutput value: + eventOutput(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePrice" + ); + } } /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. /// - /// Consider using or if you need to handle every variant. + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. /// - /// - /// - /// if (instance.TryPickNewPlanBulkWithProration(out var value)) { - /// // `value` is of type `NewPlanBulkWithProrationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanBulkWithProration( - [NotNullWhen(true)] out NewPlanBulkWithProrationPrice? value - ) - { - value = this.Value as NewPlanBulkWithProrationPrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// /// /// /// - /// if (instance.TryPickNewPlanGroupedWithProratedMinimum(out var value)) { - /// // `value` is of type `NewPlanGroupedWithProratedMinimumPrice` - /// Console.WriteLine(value); - /// } + /// var result = instance.Match( + /// (NewPlanUnitPrice value) => {...}, + /// (NewPlanTieredPrice value) => {...}, + /// (NewPlanBulkPrice value) => {...}, + /// (ReplacePricePriceBulkWithFilters value) => {...}, + /// (NewPlanPackagePrice value) => {...}, + /// (NewPlanMatrixPrice value) => {...}, + /// (NewPlanThresholdTotalAmountPrice value) => {...}, + /// (NewPlanTieredPackagePrice value) => {...}, + /// (NewPlanTieredWithMinimumPrice value) => {...}, + /// (NewPlanGroupedTieredPrice value) => {...}, + /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, + /// (NewPlanPackageWithAllocationPrice value) => {...}, + /// (NewPlanUnitWithPercentPrice value) => {...}, + /// (NewPlanMatrixWithAllocationPrice value) => {...}, + /// (ReplacePricePriceTieredWithProration value) => {...}, + /// (NewPlanUnitWithProrationPrice value) => {...}, + /// (NewPlanGroupedAllocationPrice value) => {...}, + /// (NewPlanBulkWithProrationPrice value) => {...}, + /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, + /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, + /// (ReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, + /// (NewPlanGroupedTieredPackagePrice value) => {...}, + /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, + /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, + /// (ReplacePricePriceCumulativeGroupedAllocation value) => {...}, + /// (NewPlanMinimumCompositePrice value) => {...}, + /// (ReplacePricePricePercent value) => {...}, + /// (ReplacePricePriceEventOutput value) => {...} + /// ); /// /// /// - public bool TryPickNewPlanGroupedWithProratedMinimum( - [NotNullWhen(true)] out NewPlanGroupedWithProratedMinimumPrice? value + public T Match( + System::Func newPlanUnit, + System::Func newPlanTiered, + System::Func newPlanBulk, + System::Func bulkWithFilters, + System::Func newPlanPackage, + System::Func newPlanMatrix, + System::Func newPlanThresholdTotalAmount, + System::Func newPlanTieredPackage, + System::Func newPlanTieredWithMinimum, + System::Func newPlanGroupedTiered, + System::Func newPlanTieredPackageWithMinimum, + System::Func newPlanPackageWithAllocation, + System::Func newPlanUnitWithPercent, + System::Func newPlanMatrixWithAllocation, + System::Func tieredWithProration, + System::Func newPlanUnitWithProration, + System::Func newPlanGroupedAllocation, + System::Func newPlanBulkWithProration, + System::Func newPlanGroupedWithProratedMinimum, + System::Func newPlanGroupedWithMeteredMinimum, + System::Func groupedWithMinMaxThresholds, + System::Func newPlanMatrixWithDisplayName, + System::Func newPlanGroupedTieredPackage, + System::Func newPlanMaxGroupTieredPackage, + System::Func< + NewPlanScalableMatrixWithUnitPricingPrice, + T + > newPlanScalableMatrixWithUnitPricing, + System::Func< + NewPlanScalableMatrixWithTieredPricingPrice, + T + > newPlanScalableMatrixWithTieredPricing, + System::Func newPlanCumulativeGroupedBulk, + System::Func cumulativeGroupedAllocation, + System::Func newPlanMinimumComposite, + System::Func percent, + System::Func eventOutput ) { - value = this.Value as NewPlanGroupedWithProratedMinimumPrice; - return value != null; + return this.Value switch + { + NewPlanUnitPrice value => newPlanUnit(value), + NewPlanTieredPrice value => newPlanTiered(value), + NewPlanBulkPrice value => newPlanBulk(value), + ReplacePricePriceBulkWithFilters value => bulkWithFilters(value), + NewPlanPackagePrice value => newPlanPackage(value), + NewPlanMatrixPrice value => newPlanMatrix(value), + NewPlanThresholdTotalAmountPrice value => newPlanThresholdTotalAmount(value), + NewPlanTieredPackagePrice value => newPlanTieredPackage(value), + NewPlanTieredWithMinimumPrice value => newPlanTieredWithMinimum(value), + NewPlanGroupedTieredPrice value => newPlanGroupedTiered(value), + NewPlanTieredPackageWithMinimumPrice value => newPlanTieredPackageWithMinimum(value), + NewPlanPackageWithAllocationPrice value => newPlanPackageWithAllocation(value), + NewPlanUnitWithPercentPrice value => newPlanUnitWithPercent(value), + NewPlanMatrixWithAllocationPrice value => newPlanMatrixWithAllocation(value), + ReplacePricePriceTieredWithProration value => tieredWithProration(value), + NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), + NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), + NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), + NewPlanGroupedWithProratedMinimumPrice value => newPlanGroupedWithProratedMinimum( + value + ), + NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), + ReplacePricePriceGroupedWithMinMaxThresholds value => groupedWithMinMaxThresholds( + value + ), + NewPlanMatrixWithDisplayNamePrice value => newPlanMatrixWithDisplayName(value), + NewPlanGroupedTieredPackagePrice value => newPlanGroupedTieredPackage(value), + NewPlanMaxGroupTieredPackagePrice value => newPlanMaxGroupTieredPackage(value), + NewPlanScalableMatrixWithUnitPricingPrice value => newPlanScalableMatrixWithUnitPricing( + value + ), + NewPlanScalableMatrixWithTieredPricingPrice value => + newPlanScalableMatrixWithTieredPricing(value), + NewPlanCumulativeGroupedBulkPrice value => newPlanCumulativeGroupedBulk(value), + ReplacePricePriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation( + value + ), + NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), + ReplacePricePricePercent value => percent(value), + ReplacePricePriceEventOutput value => eventOutput(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePrice" + ), + }; } + public static implicit operator ReplacePricePrice(NewPlanUnitPrice value) => new(value); + + public static implicit operator ReplacePricePrice(NewPlanTieredPrice value) => new(value); + + public static implicit operator ReplacePricePrice(NewPlanBulkPrice value) => new(value); + + public static implicit operator ReplacePricePrice(ReplacePricePriceBulkWithFilters value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanPackagePrice value) => new(value); + + public static implicit operator ReplacePricePrice(NewPlanMatrixPrice value) => new(value); + + public static implicit operator ReplacePricePrice(NewPlanThresholdTotalAmountPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanTieredPackagePrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanTieredWithMinimumPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanGroupedTieredPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanTieredPackageWithMinimumPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanPackageWithAllocationPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanUnitWithPercentPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanMatrixWithAllocationPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(ReplacePricePriceTieredWithProration value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanUnitWithProrationPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanGroupedAllocationPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanBulkWithProrationPrice value) => + new(value); + + public static implicit operator ReplacePricePrice( + NewPlanGroupedWithProratedMinimumPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + NewPlanGroupedWithMeteredMinimumPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + ReplacePricePriceGroupedWithMinMaxThresholds value + ) => new(value); + + public static implicit operator ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanGroupedTieredPackagePrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value) => + new(value); + + public static implicit operator ReplacePricePrice( + NewPlanScalableMatrixWithUnitPricingPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + NewPlanScalableMatrixWithTieredPricingPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice(NewPlanCumulativeGroupedBulkPrice value) => + new(value); + + public static implicit operator ReplacePricePrice( + ReplacePricePriceCumulativeGroupedAllocation value + ) => new(value); + + public static implicit operator ReplacePricePrice(NewPlanMinimumCompositePrice value) => + new(value); + + public static implicit operator ReplacePricePrice(ReplacePricePricePercent value) => new(value); + + public static implicit operator ReplacePricePrice(ReplacePricePriceEventOutput value) => + new(value); + /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). /// - /// Consider using or if you need to handle every variant. + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). /// - /// - /// - /// if (instance.TryPickNewPlanGroupedWithMeteredMinimum(out var value)) { - /// // `value` is of type `NewPlanGroupedWithMeteredMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// + /// Thrown when the instance does not pass validation. + /// /// - public bool TryPickNewPlanGroupedWithMeteredMinimum( - [NotNullWhen(true)] out NewPlanGroupedWithMeteredMinimumPrice? value - ) + public override void Validate() { - value = this.Value as NewPlanGroupedWithMeteredMinimumPrice; - return value != null; + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePrice" + ); + } + this.Switch( + (newPlanUnit) => newPlanUnit.Validate(), + (newPlanTiered) => newPlanTiered.Validate(), + (newPlanBulk) => newPlanBulk.Validate(), + (bulkWithFilters) => bulkWithFilters.Validate(), + (newPlanPackage) => newPlanPackage.Validate(), + (newPlanMatrix) => newPlanMatrix.Validate(), + (newPlanThresholdTotalAmount) => newPlanThresholdTotalAmount.Validate(), + (newPlanTieredPackage) => newPlanTieredPackage.Validate(), + (newPlanTieredWithMinimum) => newPlanTieredWithMinimum.Validate(), + (newPlanGroupedTiered) => newPlanGroupedTiered.Validate(), + (newPlanTieredPackageWithMinimum) => newPlanTieredPackageWithMinimum.Validate(), + (newPlanPackageWithAllocation) => newPlanPackageWithAllocation.Validate(), + (newPlanUnitWithPercent) => newPlanUnitWithPercent.Validate(), + (newPlanMatrixWithAllocation) => newPlanMatrixWithAllocation.Validate(), + (tieredWithProration) => tieredWithProration.Validate(), + (newPlanUnitWithProration) => newPlanUnitWithProration.Validate(), + (newPlanGroupedAllocation) => newPlanGroupedAllocation.Validate(), + (newPlanBulkWithProration) => newPlanBulkWithProration.Validate(), + (newPlanGroupedWithProratedMinimum) => newPlanGroupedWithProratedMinimum.Validate(), + (newPlanGroupedWithMeteredMinimum) => newPlanGroupedWithMeteredMinimum.Validate(), + (groupedWithMinMaxThresholds) => groupedWithMinMaxThresholds.Validate(), + (newPlanMatrixWithDisplayName) => newPlanMatrixWithDisplayName.Validate(), + (newPlanGroupedTieredPackage) => newPlanGroupedTieredPackage.Validate(), + (newPlanMaxGroupTieredPackage) => newPlanMaxGroupTieredPackage.Validate(), + (newPlanScalableMatrixWithUnitPricing) => + newPlanScalableMatrixWithUnitPricing.Validate(), + (newPlanScalableMatrixWithTieredPricing) => + newPlanScalableMatrixWithTieredPricing.Validate(), + (newPlanCumulativeGroupedBulk) => newPlanCumulativeGroupedBulk.Validate(), + (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), + (newPlanMinimumComposite) => newPlanMinimumComposite.Validate(), + (percent) => percent.Validate(), + (eventOutput) => eventOutput.Validate() + ); } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickGroupedWithMinMaxThresholds(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds? value - ) + public virtual bool Equals(ReplacePricePrice? other) { - value = - this.Value - as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds; - return value != null; + return other != null && JsonElement.DeepEquals(this.Json, other.Json); } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanMatrixWithDisplayName(out var value)) { - /// // `value` is of type `NewPlanMatrixWithDisplayNamePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMatrixWithDisplayName( - [NotNullWhen(true)] out NewPlanMatrixWithDisplayNamePrice? value - ) + public override int GetHashCode() { - value = this.Value as NewPlanMatrixWithDisplayNamePrice; - return value != null; + return 0; } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanGroupedTieredPackage(out var value)) { - /// // `value` is of type `NewPlanGroupedTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanGroupedTieredPackage( - [NotNullWhen(true)] out NewPlanGroupedTieredPackagePrice? value - ) - { - value = this.Value as NewPlanGroupedTieredPackagePrice; - return value != null; - } + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanMaxGroupTieredPackage(out var value)) { - /// // `value` is of type `NewPlanMaxGroupTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMaxGroupTieredPackage( - [NotNullWhen(true)] out NewPlanMaxGroupTieredPackagePrice? value +sealed class ReplacePricePriceConverter : JsonConverter +{ + public override ReplacePricePrice? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - value = this.Value as NewPlanMaxGroupTieredPackagePrice; - return value != null; - } + var element = JsonSerializer.Deserialize(ref reader, options); + string? modelType; + try + { + modelType = element.GetProperty("model_type").GetString(); + } + catch + { + modelType = null; + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanScalableMatrixWithUnitPricing(out var value)) { - /// // `value` is of type `NewPlanScalableMatrixWithUnitPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanScalableMatrixWithUnitPricing( - [NotNullWhen(true)] out NewPlanScalableMatrixWithUnitPricingPrice? value - ) - { - value = this.Value as NewPlanScalableMatrixWithUnitPricingPrice; - return value != null; - } + switch (modelType) + { + case "unit": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanScalableMatrixWithTieredPricing(out var value)) { - /// // `value` is of type `NewPlanScalableMatrixWithTieredPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanScalableMatrixWithTieredPricing( - [NotNullWhen(true)] out NewPlanScalableMatrixWithTieredPricingPrice? value - ) - { - value = this.Value as NewPlanScalableMatrixWithTieredPricingPrice; - return value != null; - } + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanCumulativeGroupedBulk(out var value)) { - /// // `value` is of type `NewPlanCumulativeGroupedBulkPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanCumulativeGroupedBulk( - [NotNullWhen(true)] out NewPlanCumulativeGroupedBulkPrice? value - ) - { - value = this.Value as NewPlanCumulativeGroupedBulkPrice; - return value != null; - } + return new(element); + } + case "bulk": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation? value - ) - { - value = - this.Value - as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation; - return value != null; - } + return new(element); + } + case "bulk_with_filters": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum? value - ) - { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanMinimumComposite(out var value)) { - /// // `value` is of type `NewPlanMinimumCompositePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMinimumComposite( - [NotNullWhen(true)] out NewPlanMinimumCompositePrice? value - ) - { - value = this.Value as NewPlanMinimumCompositePrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickPercent(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickPercent( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent? value - ) - { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickEventOutput(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickEventOutput( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput? value - ) - { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput; - return value != null; - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (NewPlanUnitPrice value) => {...}, - /// (NewPlanTieredPrice value) => {...}, - /// (NewPlanBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value) => {...}, - /// (NewPlanPackagePrice value) => {...}, - /// (NewPlanMatrixPrice value) => {...}, - /// (NewPlanThresholdTotalAmountPrice value) => {...}, - /// (NewPlanTieredPackagePrice value) => {...}, - /// (NewPlanTieredWithMinimumPrice value) => {...}, - /// (NewPlanGroupedTieredPrice value) => {...}, - /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, - /// (NewPlanPackageWithAllocationPrice value) => {...}, - /// (NewPlanUnitWithPercentPrice value) => {...}, - /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value) => {...}, - /// (NewPlanUnitWithProrationPrice value) => {...}, - /// (NewPlanGroupedAllocationPrice value) => {...}, - /// (NewPlanBulkWithProrationPrice value) => {...}, - /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, - /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, - /// (NewPlanGroupedTieredPackagePrice value) => {...}, - /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, - /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value) => {...}, - /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action newPlanUnit, - System::Action newPlanTiered, - System::Action newPlanBulk, - System::Action bulkWithFilters, - System::Action newPlanPackage, - System::Action newPlanMatrix, - System::Action newPlanThresholdTotalAmount, - System::Action newPlanTieredPackage, - System::Action newPlanTieredWithMinimum, - System::Action newPlanGroupedTiered, - System::Action newPlanTieredPackageWithMinimum, - System::Action newPlanPackageWithAllocation, - System::Action newPlanUnitWithPercent, - System::Action newPlanMatrixWithAllocation, - System::Action tieredWithProration, - System::Action newPlanUnitWithProration, - System::Action newPlanGroupedAllocation, - System::Action newPlanBulkWithProration, - System::Action newPlanGroupedWithProratedMinimum, - System::Action newPlanGroupedWithMeteredMinimum, - System::Action groupedWithMinMaxThresholds, - System::Action newPlanMatrixWithDisplayName, - System::Action newPlanGroupedTieredPackage, - System::Action newPlanMaxGroupTieredPackage, - System::Action newPlanScalableMatrixWithUnitPricing, - System::Action newPlanScalableMatrixWithTieredPricing, - System::Action newPlanCumulativeGroupedBulk, - System::Action cumulativeGroupedAllocation, - System::Action minimum, - System::Action newPlanMinimumComposite, - System::Action percent, - System::Action eventOutput - ) - { - switch (this.Value) - { - case NewPlanUnitPrice value: - newPlanUnit(value); - break; - case NewPlanTieredPrice value: - newPlanTiered(value); - break; - case NewPlanBulkPrice value: - newPlanBulk(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value: - bulkWithFilters(value); - break; - case NewPlanPackagePrice value: - newPlanPackage(value); - break; - case NewPlanMatrixPrice value: - newPlanMatrix(value); - break; - case NewPlanThresholdTotalAmountPrice value: - newPlanThresholdTotalAmount(value); - break; - case NewPlanTieredPackagePrice value: - newPlanTieredPackage(value); - break; - case NewPlanTieredWithMinimumPrice value: - newPlanTieredWithMinimum(value); - break; - case NewPlanGroupedTieredPrice value: - newPlanGroupedTiered(value); - break; - case NewPlanTieredPackageWithMinimumPrice value: - newPlanTieredPackageWithMinimum(value); - break; - case NewPlanPackageWithAllocationPrice value: - newPlanPackageWithAllocation(value); - break; - case NewPlanUnitWithPercentPrice value: - newPlanUnitWithPercent(value); - break; - case NewPlanMatrixWithAllocationPrice value: - newPlanMatrixWithAllocation(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value: - tieredWithProration(value); - break; - case NewPlanUnitWithProrationPrice value: - newPlanUnitWithProration(value); - break; - case NewPlanGroupedAllocationPrice value: - newPlanGroupedAllocation(value); - break; - case NewPlanBulkWithProrationPrice value: - newPlanBulkWithProration(value); - break; - case NewPlanGroupedWithProratedMinimumPrice value: - newPlanGroupedWithProratedMinimum(value); - break; - case NewPlanGroupedWithMeteredMinimumPrice value: - newPlanGroupedWithMeteredMinimum(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value: - groupedWithMinMaxThresholds(value); - break; - case NewPlanMatrixWithDisplayNamePrice value: - newPlanMatrixWithDisplayName(value); - break; - case NewPlanGroupedTieredPackagePrice value: - newPlanGroupedTieredPackage(value); - break; - case NewPlanMaxGroupTieredPackagePrice value: - newPlanMaxGroupTieredPackage(value); - break; - case NewPlanScalableMatrixWithUnitPricingPrice value: - newPlanScalableMatrixWithUnitPricing(value); - break; - case NewPlanScalableMatrixWithTieredPricingPrice value: - newPlanScalableMatrixWithTieredPricing(value); - break; - case NewPlanCumulativeGroupedBulkPrice value: - newPlanCumulativeGroupedBulk(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value: - cumulativeGroupedAllocation(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value: - minimum(value); - break; - case NewPlanMinimumCompositePrice value: - newPlanMinimumComposite(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value: - percent(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value: - eventOutput(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ); - } - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (NewPlanUnitPrice value) => {...}, - /// (NewPlanTieredPrice value) => {...}, - /// (NewPlanBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value) => {...}, - /// (NewPlanPackagePrice value) => {...}, - /// (NewPlanMatrixPrice value) => {...}, - /// (NewPlanThresholdTotalAmountPrice value) => {...}, - /// (NewPlanTieredPackagePrice value) => {...}, - /// (NewPlanTieredWithMinimumPrice value) => {...}, - /// (NewPlanGroupedTieredPrice value) => {...}, - /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, - /// (NewPlanPackageWithAllocationPrice value) => {...}, - /// (NewPlanUnitWithPercentPrice value) => {...}, - /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value) => {...}, - /// (NewPlanUnitWithProrationPrice value) => {...}, - /// (NewPlanGroupedAllocationPrice value) => {...}, - /// (NewPlanBulkWithProrationPrice value) => {...}, - /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, - /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, - /// (NewPlanGroupedTieredPackagePrice value) => {...}, - /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, - /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value) => {...}, - /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func newPlanUnit, - System::Func newPlanTiered, - System::Func newPlanBulk, - System::Func< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters, - T - > bulkWithFilters, - System::Func newPlanPackage, - System::Func newPlanMatrix, - System::Func newPlanThresholdTotalAmount, - System::Func newPlanTieredPackage, - System::Func newPlanTieredWithMinimum, - System::Func newPlanGroupedTiered, - System::Func newPlanTieredPackageWithMinimum, - System::Func newPlanPackageWithAllocation, - System::Func newPlanUnitWithPercent, - System::Func newPlanMatrixWithAllocation, - System::Func< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration, - T - > tieredWithProration, - System::Func newPlanUnitWithProration, - System::Func newPlanGroupedAllocation, - System::Func newPlanBulkWithProration, - System::Func newPlanGroupedWithProratedMinimum, - System::Func newPlanGroupedWithMeteredMinimum, - System::Func< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds, - T - > groupedWithMinMaxThresholds, - System::Func newPlanMatrixWithDisplayName, - System::Func newPlanGroupedTieredPackage, - System::Func newPlanMaxGroupTieredPackage, - System::Func< - NewPlanScalableMatrixWithUnitPricingPrice, - T - > newPlanScalableMatrixWithUnitPricing, - System::Func< - NewPlanScalableMatrixWithTieredPricingPrice, - T - > newPlanScalableMatrixWithTieredPricing, - System::Func newPlanCumulativeGroupedBulk, - System::Func< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation, - T - > cumulativeGroupedAllocation, - System::Func minimum, - System::Func newPlanMinimumComposite, - System::Func percent, - System::Func< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput, - T - > eventOutput - ) - { - return this.Value switch - { - NewPlanUnitPrice value => newPlanUnit(value), - NewPlanTieredPrice value => newPlanTiered(value), - NewPlanBulkPrice value => newPlanBulk(value), - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value => - bulkWithFilters(value), - NewPlanPackagePrice value => newPlanPackage(value), - NewPlanMatrixPrice value => newPlanMatrix(value), - NewPlanThresholdTotalAmountPrice value => newPlanThresholdTotalAmount(value), - NewPlanTieredPackagePrice value => newPlanTieredPackage(value), - NewPlanTieredWithMinimumPrice value => newPlanTieredWithMinimum(value), - NewPlanGroupedTieredPrice value => newPlanGroupedTiered(value), - NewPlanTieredPackageWithMinimumPrice value => newPlanTieredPackageWithMinimum(value), - NewPlanPackageWithAllocationPrice value => newPlanPackageWithAllocation(value), - NewPlanUnitWithPercentPrice value => newPlanUnitWithPercent(value), - NewPlanMatrixWithAllocationPrice value => newPlanMatrixWithAllocation(value), - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value => - tieredWithProration(value), - NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), - NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), - NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), - NewPlanGroupedWithProratedMinimumPrice value => newPlanGroupedWithProratedMinimum( - value - ), - NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value => - groupedWithMinMaxThresholds(value), - NewPlanMatrixWithDisplayNamePrice value => newPlanMatrixWithDisplayName(value), - NewPlanGroupedTieredPackagePrice value => newPlanGroupedTieredPackage(value), - NewPlanMaxGroupTieredPackagePrice value => newPlanMaxGroupTieredPackage(value), - NewPlanScalableMatrixWithUnitPricingPrice value => newPlanScalableMatrixWithUnitPricing( - value - ), - NewPlanScalableMatrixWithTieredPricingPrice value => - newPlanScalableMatrixWithTieredPricing(value), - NewPlanCumulativeGroupedBulkPrice value => newPlanCumulativeGroupedBulk(value), - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value => - cumulativeGroupedAllocation(value), - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value => minimum(value), - NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value => percent(value), - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value => - eventOutput(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ), - }; - } - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanUnitPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanTieredPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanBulkPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanPackagePrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMatrixPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanThresholdTotalAmountPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanTieredPackagePrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanTieredWithMinimumPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedTieredPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanTieredPackageWithMinimumPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanPackageWithAllocationPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanUnitWithPercentPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMatrixWithAllocationPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanUnitWithProrationPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedAllocationPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanBulkWithProrationPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedWithProratedMinimumPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedWithMeteredMinimumPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMatrixWithDisplayNamePrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedTieredPackagePrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMaxGroupTieredPackagePrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanScalableMatrixWithUnitPricingPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanScalableMatrixWithTieredPricingPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanCumulativeGroupedBulkPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMinimumCompositePrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value - ) => new(value); - - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() - { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ); - } - this.Switch( - (newPlanUnit) => newPlanUnit.Validate(), - (newPlanTiered) => newPlanTiered.Validate(), - (newPlanBulk) => newPlanBulk.Validate(), - (bulkWithFilters) => bulkWithFilters.Validate(), - (newPlanPackage) => newPlanPackage.Validate(), - (newPlanMatrix) => newPlanMatrix.Validate(), - (newPlanThresholdTotalAmount) => newPlanThresholdTotalAmount.Validate(), - (newPlanTieredPackage) => newPlanTieredPackage.Validate(), - (newPlanTieredWithMinimum) => newPlanTieredWithMinimum.Validate(), - (newPlanGroupedTiered) => newPlanGroupedTiered.Validate(), - (newPlanTieredPackageWithMinimum) => newPlanTieredPackageWithMinimum.Validate(), - (newPlanPackageWithAllocation) => newPlanPackageWithAllocation.Validate(), - (newPlanUnitWithPercent) => newPlanUnitWithPercent.Validate(), - (newPlanMatrixWithAllocation) => newPlanMatrixWithAllocation.Validate(), - (tieredWithProration) => tieredWithProration.Validate(), - (newPlanUnitWithProration) => newPlanUnitWithProration.Validate(), - (newPlanGroupedAllocation) => newPlanGroupedAllocation.Validate(), - (newPlanBulkWithProration) => newPlanBulkWithProration.Validate(), - (newPlanGroupedWithProratedMinimum) => newPlanGroupedWithProratedMinimum.Validate(), - (newPlanGroupedWithMeteredMinimum) => newPlanGroupedWithMeteredMinimum.Validate(), - (groupedWithMinMaxThresholds) => groupedWithMinMaxThresholds.Validate(), - (newPlanMatrixWithDisplayName) => newPlanMatrixWithDisplayName.Validate(), - (newPlanGroupedTieredPackage) => newPlanGroupedTieredPackage.Validate(), - (newPlanMaxGroupTieredPackage) => newPlanMaxGroupTieredPackage.Validate(), - (newPlanScalableMatrixWithUnitPricing) => - newPlanScalableMatrixWithUnitPricing.Validate(), - (newPlanScalableMatrixWithTieredPricing) => - newPlanScalableMatrixWithTieredPricing.Validate(), - (newPlanCumulativeGroupedBulk) => newPlanCumulativeGroupedBulk.Validate(), - (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), - (newPlanMinimumComposite) => newPlanMinimumComposite.Validate(), - (percent) => percent.Validate(), - (eventOutput) => eventOutput.Validate() - ); - } - - public virtual bool Equals(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } - - public override int GetHashCode() - { - return 0; - } - - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class ReplacePricePriceConverter - : JsonConverter -{ - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - string? modelType; - try - { - modelType = element.GetProperty("model_type").GetString(); - } - catch - { - modelType = null; - } - - switch (modelType) - { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "bulk": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "bulk_with_filters": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "package": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "matrix": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "threshold_total_amount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_package": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_with_minimum": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_package_with_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "package_with_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "unit_with_percent": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "matrix_with_allocation": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_with_proration": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "unit_with_proration": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_allocation": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "bulk_with_proration": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_prorated_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_metered_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_min_max_thresholds": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "matrix_with_display_name": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_tiered_package": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "max_group_tiered_package": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "scalable_matrix_with_unit_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "scalable_matrix_with_tiered_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "cumulative_grouped_bulk": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "cumulative_grouped_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum_composite": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "percent": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "event_output": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice(element); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice? value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value?.Json, options); - } -} - -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersFromRaw - >) -)] -public sealed record class ReplacePricePriceBulkWithFilters : JsonModel -{ - /// - /// Configuration for bulk_with_filters pricing - /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "bulk_with_filters_config" - ); - } - init { this._rawData.Set("bulk_with_filters_config", value); } - } - - /// - /// The cadence to bill for this price on. - /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadence - > Cadence - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadence - > - >("cadence"); - } - init { this._rawData.Set("cadence", value); } - } - - /// - /// The id of the item the price will be associated with. - /// - public required string ItemID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); - } - init { this._rawData.Set("item_id", value); } - } - - /// - /// The pricing model type - /// - public JsonElement ModelType - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); - } - init { this._rawData.Set("model_type", value); } - } - - /// - /// The name of the price. - /// - public required string Name - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } - } - - /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. - /// - public string? BillableMetricID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); - } - init { this._rawData.Set("billable_metric_id", value); } - } - - /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. - /// - public bool? BilledInAdvance - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); - } - init { this._rawData.Set("billed_in_advance", value); } - } - - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } - } - - /// - /// The per unit conversion rate of the price currency to the invoicing currency. - /// - public double? ConversionRate - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); - } - init { this._rawData.Set("conversion_rate", value); } - } - - /// - /// The configuration for the rate of the price currency to the invoicing currency. - /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", value); } - } - - /// - /// An ISO 4217 currency string, or custom pricing unit identifier, in which - /// this price is billed. - /// - public string? Currency - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("currency"); - } - init { this._rawData.Set("currency", value); } - } - - /// - /// For dimensional price: specifies a price group and dimension values - /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } - } - - /// - /// An alias for the price. - /// - public string? ExternalPriceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } - } - - /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. - /// - public double? FixedPriceQuantity - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } - } - - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", value); } - } - - /// - /// Within each billing cycle, specifies the cadence at which invoices are produced. - /// If unspecified, a single invoice is produced per billing cycle. - /// - public NewBillingCycleConfiguration? InvoicingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); - } - init { this._rawData.Set("invoicing_cycle_configuration", value); } - } - - /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared - /// by setting `metadata` to `null`. - /// - public IReadOnlyDictionary? Metadata - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) - ); - } - } - - /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. - /// - public string? ReferenceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("reference_id"); - } - init { this._rawData.Set("reference_id", value); } - } - - /// - public override void Validate() - { - this.BulkWithFiltersConfig.Validate(); - this.Cadence.Validate(); - _ = this.ItemID; - if ( - !JsonElement.DeepEquals( - this.ModelType, - JsonSerializer.SerializeToElement("bulk_with_filters") - ) - ) - { - throw new OrbInvalidDataException("Invalid value given for constant"); - } - _ = this.Name; - _ = this.BillableMetricID; - _ = this.BilledInAdvance; - this.BillingCycleConfiguration?.Validate(); - _ = this.ConversionRate; - this.ConversionRateConfig?.Validate(); - _ = this.Currency; - this.DimensionalPriceConfiguration?.Validate(); - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.InvoiceGroupingKey; - this.InvoicingCycleConfiguration?.Validate(); - _ = this.Metadata; - _ = this.ReferenceID; - } - - public ReplacePricePriceBulkWithFilters() - { - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - } - - public ReplacePricePriceBulkWithFilters( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters - ) - : base(replacePricePriceBulkWithFilters) { } - - public ReplacePricePriceBulkWithFilters(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceBulkWithFilters(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class ReplacePricePriceBulkWithFiltersFromRaw - : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters.FromRawUnchecked( - rawData - ); -} - -/// -/// Configuration for bulk_with_filters pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw - >) -)] -public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig : JsonModel -{ - /// - /// Property filters to apply (all must match) - /// - public required IReadOnlyList Filters - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("filters"); - } - init - { - this._rawData.Set< - ImmutableArray - >("filters", ImmutableArray.ToImmutableArray(value)); - } - } - - /// - /// Bulk tiers for rating based on total usage volume - /// - public required IReadOnlyList Tiers - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); - } - init - { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); - } - } - - /// - public override void Validate() - { - foreach (var item in this.Filters) - { - item.Validate(); - } - foreach (var item in this.Tiers) - { - item.Validate(); - } - } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig - ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfig) { } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw - : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked( - rawData - ); -} - -/// -/// Configuration for a single property filter -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw - >) -)] -public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter : JsonModel -{ - /// - /// Event property key to filter on - /// - public required string PropertyKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_key"); - } - init { this._rawData.Set("property_key", value); } - } - - /// - /// Event property value to match - /// - public required string PropertyValue - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_value"); - } - init { this._rawData.Set("property_value", value); } - } - - /// - public override void Validate() - { - _ = this.PropertyKey; - _ = this.PropertyValue; - } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw - : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked( - rawData - ); -} - -/// -/// Configuration for a single bulk pricing tier -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw - >) -)] -public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier : JsonModel -{ - /// - /// Amount per unit - /// - public required string UnitAmount - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); - } - init { this._rawData.Set("unit_amount", value); } - } - - /// - /// The lower bound for this tier - /// - public string? TierLowerBound - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("tier_lower_bound"); - } - init { this._rawData.Set("tier_lower_bound", value); } - } - - /// - public override void Validate() - { - _ = this.UnitAmount; - _ = this.TierLowerBound; - } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 + return new(element); + } + case "package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } + return new(element); + } + case "matrix": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - [SetsRequiredMembers] - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier(string unitAmount) - : this() - { - this.UnitAmount = unitAmount; - } -} + return new(element); + } + case "threshold_total_amount": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw - : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked( - rawData - ); -} + return new(element); + } + case "tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -/// -/// The cadence to bill for this price on. -/// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadenceConverter) -)] -public enum ReplacePricePriceBulkWithFiltersCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} + return new(element); + } + case "tiered_with_minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -sealed class ReplacePricePriceBulkWithFiltersCadenceConverter - : JsonConverter -{ - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .Annual, - "semi_annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .SemiAnnual, - "monthly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .Monthly, - "quarterly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .Quarterly, - "one_time" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .OneTime, - "custom" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .Custom, - _ => (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadence)( - -1 - ), - }; - } + return new(element); + } + case "grouped_tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch + return new(element); + } + case "tiered_package_with_minimum": { - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .Annual => "annual", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .SemiAnnual => "semi_annual", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .Monthly => "monthly", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .Quarterly => "quarterly", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .OneTime => "one_time", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfigConverter) -)] -public record class ReplacePricePriceBulkWithFiltersConversionRateConfig : ModelBase -{ - public object? Value { get; } = null; + return new(element); + } + case "package_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - JsonElement? _element = null; + return new(element); + } + case "unit_with_percent": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public JsonElement Json - { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } - } + return new(element); + } + case "matrix_with_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + return new(element); + } + case "tiered_with_proration": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } + + return new(element); + } + case "unit_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + return new(element); + } + case "grouped_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) - { - this._element = element; - } + return new(element); + } + case "bulk_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) - { - value = this.Value as SharedUnitConversionRateConfig; - return value != null; - } + return new(element); + } + case "grouped_with_prorated_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) - { - value = this.Value as SharedTieredConversionRateConfig; - return value != null; - } + return new(element); + } + case "grouped_with_metered_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action unit, - System::Action tiered - ) - { - switch (this.Value) - { - case SharedUnitConversionRateConfig value: - unit(value); - break; - case SharedTieredConversionRateConfig value: - tiered(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" - ); - } - } + return new(element); + } + case "grouped_with_min_max_thresholds": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func unit, - System::Func tiered - ) - { - return this.Value switch - { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" - ), - }; - } + return new(element); + } + case "matrix_with_display_name": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); + return new(element); + } + case "grouped_tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); + return new(element); + } + case "max_group_tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() - { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" - ); - } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); - } + return new(element); + } + case "scalable_matrix_with_unit_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + return new(element); + } + case "scalable_matrix_with_tiered_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public override int GetHashCode() - { - return 0; - } + return new(element); + } + case "cumulative_grouped_bulk": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} + return new(element); + } + case "cumulative_grouped_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -sealed class ReplacePricePriceBulkWithFiltersConversionRateConfigConverter - : JsonConverter -{ - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; - try - { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); - } - catch - { - conversionRateType = null; - } + return new(element); + } + case "minimum_composite": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - switch (conversionRateType) - { - case "unit": + return new(element); + } + case "percent": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -14306,11 +11780,11 @@ JsonSerializerOptions options return new(element); } - case "tiered": + case "event_output": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -14330,47 +11804,54 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig( - element - ); + return new ReplacePricePrice(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig value, + ReplacePricePrice? value, JsonSerializerOptions options ) { - JsonSerializer.Serialize(writer, value.Json, options); + JsonSerializer.Serialize(writer, value?.Json, options); } } [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationFromRaw + ReplacePricePriceBulkWithFilters, + ReplacePricePriceBulkWithFiltersFromRaw >) )] -public sealed record class ReplacePricePriceTieredWithProration : JsonModel +public sealed record class ReplacePricePriceBulkWithFilters : JsonModel { + /// + /// Configuration for bulk_with_filters pricing + /// + public required ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "bulk_with_filters_config" + ); + } + init { this._rawData.Set("bulk_with_filters_config", value); } + } + /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationCadence - > + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -14409,25 +11890,10 @@ public required string Name { get { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } - } - - /// - /// Configuration for tiered_with_proration pricing - /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfig TieredWithProrationConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "tiered_with_proration_config" - ); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); } - init { this._rawData.Set("tiered_with_proration_config", value); } + init { this._rawData.Set("name", value); } } /// @@ -14489,12 +11955,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig? ConversionRateConfig + public ReplacePricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -14623,19 +12089,19 @@ public string? ReferenceID /// public override void Validate() { + this.BulkWithFiltersConfig.Validate(); this.Cadence.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("tiered_with_proration") + JsonSerializer.SerializeToElement("bulk_with_filters") ) ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.TieredWithProrationConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -14651,33 +12117,33 @@ public override void Validate() _ = this.ReferenceID; } - public ReplacePricePriceTieredWithProration() + public ReplacePricePriceBulkWithFilters() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } - public ReplacePricePriceTieredWithProration( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration replacePricePriceTieredWithProration + public ReplacePricePriceBulkWithFilters( + ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters ) - : base(replacePricePriceTieredWithProration) { } + : base(replacePricePriceBulkWithFilters) { } - public ReplacePricePriceTieredWithProration(IReadOnlyDictionary rawData) + public ReplacePricePriceBulkWithFilters(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProration(FrozenDictionary rawData) + ReplacePricePriceBulkWithFilters(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration FromRawUnchecked( + /// + public static ReplacePricePriceBulkWithFilters FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -14685,171 +12151,61 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceTieredWithProrationFromRaw - : IFromRawJson +class ReplacePricePriceBulkWithFiltersFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration FromRawUnchecked( + public ReplacePricePriceBulkWithFilters FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration.FromRawUnchecked( - rawData - ); + ) => ReplacePricePriceBulkWithFilters.FromRawUnchecked(rawData); } /// -/// The cadence to bill for this price on. +/// Configuration for bulk_with_filters pricing /// [JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationCadenceConverter) + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + >) )] -public enum ReplacePricePriceTieredWithProrationCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class ReplacePricePriceTieredWithProrationCadenceConverter - : JsonConverter +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig : JsonModel { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + /// + /// Property filters to apply (all must match) + /// + public required IReadOnlyList Filters { - return JsonSerializer.Deserialize(ref reader, options) switch + get { - "annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .Annual, - "semi_annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .SemiAnnual, - "monthly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .Monthly, - "quarterly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .Quarterly, - "one_time" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .OneTime, - "custom" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .Custom, - _ => - (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationCadence)( - -1 - ), - }; - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .Annual => "annual", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .SemiAnnual => "semi_annual", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .Monthly => "monthly", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .Quarterly => "quarterly", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .OneTime => "one_time", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("filters"); + } + init + { + this._rawData.Set< + ImmutableArray + >("filters", ImmutableArray.ToImmutableArray(value)); + } } -} -/// -/// Configuration for tiered_with_proration pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfig, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw - >) -)] -public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfig : JsonModel -{ /// - /// Tiers for rating based on total usage quantities into the specified tier - /// with proration + /// Bulk tiers for rating based on total usage volume /// - public required IReadOnlyList Tiers + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); return this._rawData.GetNotNullStruct< - ImmutableArray + ImmutableArray >("tiers"); } init { this._rawData.Set< - ImmutableArray + ImmutableArray >("tiers", ImmutableArray.ToImmutableArray(value)); } } @@ -14857,20 +12213,24 @@ public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrati /// public override void Validate() { + foreach (var item in this.Filters) + { + item.Validate(); + } foreach (var item in this.Tiers) { item.Validate(); } } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig() { } + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfig replacePricePriceTieredWithProrationTieredWithProrationConfig + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig ) - : base(replacePricePriceTieredWithProrationTieredWithProrationConfig) { } + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfig) { } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( IReadOnlyDictionary rawData ) { @@ -14879,7 +12239,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( FrozenDictionary rawData ) { @@ -14887,130 +12247,265 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} + +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single property filter +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + >) +)] +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter : JsonModel +{ + /// + /// Event property key to filter on + /// + public required string PropertyKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("property_key"); + } + init { this._rawData.Set("property_key", value); } + } + + /// + /// Event property value to match + /// + public required string PropertyValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("property_value"); + } + init { this._rawData.Set("property_value", value); } + } + + /// + public override void Validate() + { + _ = this.PropertyKey; + _ = this.PropertyValue; + } + + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } + + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + ) + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } + + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning disable CS8618 [SetsRequiredMembers] - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( - IReadOnlyList tiers + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + FrozenDictionary rawData ) - : this() { - this.Tiers = tiers; + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw - : IFromRawJson +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked( - rawData - ); + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked(rawData); } /// -/// Configuration for a single tiered with proration tier +/// Configuration for a single bulk pricing tier /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw >) )] -public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier - : JsonModel +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier : JsonModel { /// - /// Inclusive tier starting value + /// Amount per unit /// - public required string TierLowerBound + public required string UnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("unit_amount"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("unit_amount", value); } } /// - /// Amount per unit + /// The lower bound for this tier /// - public required string UnitAmount + public string? TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNullableClass("tier_lower_bound"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("tier_lower_bound", value); } } /// public override void Validate() { - _ = this.TierLowerBound; _ = this.UnitAmount; + _ = this.TierLowerBound; } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() { } + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier replacePricePriceTieredWithProrationTieredWithProrationConfigTier + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier ) - : base(replacePricePriceTieredWithProrationTieredWithProrationConfigTier) { } + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); } -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( - FrozenDictionary rawData +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier(string unitAmount) + : this() + { + this.UnitAmount = unitAmount; + } +} + +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersCadenceConverter))] +public enum ReplacePricePriceBulkWithFiltersCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePricePriceBulkWithFiltersCadenceConverter + : JsonConverter +{ + public override ReplacePricePriceBulkWithFiltersCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - this._rawData = new(rawData); + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePricePriceBulkWithFiltersCadence.Annual, + "semi_annual" => ReplacePricePriceBulkWithFiltersCadence.SemiAnnual, + "monthly" => ReplacePricePriceBulkWithFiltersCadence.Monthly, + "quarterly" => ReplacePricePriceBulkWithFiltersCadence.Quarterly, + "one_time" => ReplacePricePriceBulkWithFiltersCadence.OneTime, + "custom" => ReplacePricePriceBulkWithFiltersCadence.Custom, + _ => (ReplacePricePriceBulkWithFiltersCadence)(-1), + }; } -#pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData + public override void Write( + Utf8JsonWriter writer, + ReplacePricePriceBulkWithFiltersCadence value, + JsonSerializerOptions options ) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw - : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked( - rawData + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePricePriceBulkWithFiltersCadence.Annual => "annual", + ReplacePricePriceBulkWithFiltersCadence.SemiAnnual => "semi_annual", + ReplacePricePriceBulkWithFiltersCadence.Monthly => "monthly", + ReplacePricePriceBulkWithFiltersCadence.Quarterly => "quarterly", + ReplacePricePriceBulkWithFiltersCadence.OneTime => "one_time", + ReplacePricePriceBulkWithFiltersCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options ); + } } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfigConverter) -)] -public record class ReplacePricePriceTieredWithProrationConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersConversionRateConfigConverter))] +public record class ReplacePricePriceBulkWithFiltersConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -15027,7 +12522,7 @@ public JsonElement Json } } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15036,7 +12531,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15045,7 +12540,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) + public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) { this._element = element; } @@ -15127,7 +12622,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" ); } } @@ -15163,16 +12658,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -15191,15 +12686,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig? other - ) + public virtual bool Equals(ReplacePricePriceBulkWithFiltersConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -15213,10 +12706,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class ReplacePricePriceTieredWithProrationConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceBulkWithFiltersConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig? Read( + public override ReplacePricePriceBulkWithFiltersConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -15281,16 +12774,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig( - element - ); + return new ReplacePricePriceBulkWithFiltersConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig value, + ReplacePricePriceBulkWithFiltersConversionRateConfig value, JsonSerializerOptions options ) { @@ -15300,48 +12791,27 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + ReplacePricePriceTieredWithProration, + ReplacePricePriceTieredWithProrationFromRaw >) )] -public sealed record class ReplacePricePriceGroupedWithMinMaxThresholds : JsonModel +public sealed record class ReplacePricePriceTieredWithProration : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsCadence - > + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } } - /// - /// Configuration for grouped_with_min_max_thresholds pricing - /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_with_min_max_thresholds_config" - ); - } - init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } - } - /// /// The id of the item the price will be associated with. /// @@ -15381,6 +12851,21 @@ public required string Name init { this._rawData.Set("name", value); } } + /// + /// Configuration for tiered_with_proration pricing + /// + public required ReplacePricePriceTieredWithProrationTieredWithProrationConfig TieredWithProrationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "tiered_with_proration_config" + ); + } + init { this._rawData.Set("tiered_with_proration_config", value); } + } + /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -15440,12 +12925,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + public ReplacePricePriceTieredWithProrationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -15575,18 +13060,18 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.GroupedWithMinMaxThresholdsConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + JsonSerializer.SerializeToElement("tiered_with_proration") ) ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; + this.TieredWithProrationConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -15602,35 +13087,33 @@ public override void Validate() _ = this.ReferenceID; } - public ReplacePricePriceGroupedWithMinMaxThresholds() + public ReplacePricePriceTieredWithProration() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } - public ReplacePricePriceGroupedWithMinMaxThresholds( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds replacePricePriceGroupedWithMinMaxThresholds + public ReplacePricePriceTieredWithProration( + ReplacePricePriceTieredWithProration replacePricePriceTieredWithProration ) - : base(replacePricePriceGroupedWithMinMaxThresholds) { } + : base(replacePricePriceTieredWithProration) { } - public ReplacePricePriceGroupedWithMinMaxThresholds( - IReadOnlyDictionary rawData - ) + public ReplacePricePriceTieredWithProration(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholds(FrozenDictionary rawData) + ReplacePricePriceTieredWithProration(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15638,25 +13121,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class ReplacePricePriceTieredWithProrationFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + public ReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked( - rawData - ); + ) => ReplacePricePriceTieredWithProration.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter) -)] -public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(ReplacePricePriceTieredWithProrationCadenceConverter))] +public enum ReplacePricePriceTieredWithProrationCadence { Annual, SemiAnnual, @@ -15666,10 +13144,10 @@ public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence Custom, } -sealed class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class ReplacePricePriceTieredWithProrationCadenceConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( + public override ReplacePricePriceTieredWithProrationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -15677,52 +13155,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceGroupedWithMinMaxThresholdsCadence - .Annual, - "semi_annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceGroupedWithMinMaxThresholdsCadence - .SemiAnnual, - "monthly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceGroupedWithMinMaxThresholdsCadence - .Monthly, - "quarterly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceGroupedWithMinMaxThresholdsCadence - .Quarterly, - "one_time" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceGroupedWithMinMaxThresholdsCadence - .OneTime, - "custom" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceGroupedWithMinMaxThresholdsCadence - .Custom, - _ => - (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsCadence)( - -1 - ), + "annual" => ReplacePricePriceTieredWithProrationCadence.Annual, + "semi_annual" => ReplacePricePriceTieredWithProrationCadence.SemiAnnual, + "monthly" => ReplacePricePriceTieredWithProrationCadence.Monthly, + "quarterly" => ReplacePricePriceTieredWithProrationCadence.Quarterly, + "one_time" => ReplacePricePriceTieredWithProrationCadence.OneTime, + "custom" => ReplacePricePriceTieredWithProrationCadence.Custom, + _ => (ReplacePricePriceTieredWithProrationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsCadence value, + ReplacePricePriceTieredWithProrationCadence value, JsonSerializerOptions options ) { @@ -15730,42 +13175,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceGroupedWithMinMaxThresholdsCadence - .Annual => "annual", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceGroupedWithMinMaxThresholdsCadence - .SemiAnnual => "semi_annual", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceGroupedWithMinMaxThresholdsCadence - .Monthly => "monthly", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceGroupedWithMinMaxThresholdsCadence - .Quarterly => "quarterly", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceGroupedWithMinMaxThresholdsCadence - .OneTime => "one_time", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceGroupedWithMinMaxThresholdsCadence - .Custom => "custom", + ReplacePricePriceTieredWithProrationCadence.Annual => "annual", + ReplacePricePriceTieredWithProrationCadence.SemiAnnual => "semi_annual", + ReplacePricePriceTieredWithProrationCadence.Monthly => "monthly", + ReplacePricePriceTieredWithProrationCadence.Quarterly => "quarterly", + ReplacePricePriceTieredWithProrationCadence.OneTime => "one_time", + ReplacePricePriceTieredWithProrationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -15776,86 +13191,150 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for tiered_with_proration pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + ReplacePricePriceTieredWithProrationTieredWithProrationConfig, + ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw >) )] -public sealed record class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - : JsonModel +public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfig : JsonModel { /// - /// The event property used to group before applying thresholds + /// Tiers for rating based on total usage quantities into the specified tier + /// with proration /// - public required string GroupingKey + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); } - init { this._rawData.Set("grouping_key", value); } } - /// - /// The maximum amount to charge each group - /// - public required string MaximumCharge + /// + public override void Validate() { - get + foreach (var item in this.Tiers) { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); + item.Validate(); } - init { this._rawData.Set("maximum_charge", value); } } + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig() { } + + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + ReplacePricePriceTieredWithProrationTieredWithProrationConfig replacePricePriceTieredWithProrationTieredWithProrationConfig + ) + : base(replacePricePriceTieredWithProrationTieredWithProrationConfig) { } + + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyList tiers + ) + : this() + { + this.Tiers = tiers; + } +} + +class ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tiered with proration tier +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier, + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + >) +)] +public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + : JsonModel +{ /// - /// The minimum amount to charge each group, regardless of usage + /// Inclusive tier starting value /// - public required string MinimumCharge + public required string TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullClass("tier_lower_bound"); } - init { this._rawData.Set("minimum_charge", value); } + init { this._rawData.Set("tier_lower_bound", value); } } /// - /// The base price charged per group + /// Amount per unit /// - public required string PerUnitRate + public required string UnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("per_unit_rate"); + return this._rawData.GetNotNullClass("unit_amount"); } - init { this._rawData.Set("per_unit_rate", value); } + init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + _ = this.TierLowerBound; + _ = this.UnitAmount; } - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() { } - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier replacePricePriceTieredWithProrationTieredWithProrationConfigTier ) - : base(replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } + : base(replacePricePriceTieredWithProrationTieredWithProrationConfigTier) { } - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( IReadOnlyDictionary rawData ) { @@ -15864,7 +13343,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( FrozenDictionary rawData ) { @@ -15872,8 +13351,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15881,22 +13360,18 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( - rawData - ); + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter) -)] -public record class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceTieredWithProrationConversionRateConfigConverter))] +public record class ReplacePricePriceTieredWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -15913,7 +13388,7 @@ public JsonElement Json } } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15922,7 +13397,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15931,7 +13406,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -16013,7 +13488,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" ); } } @@ -16049,16 +13524,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -16077,15 +13552,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other - ) + public virtual bool Equals(ReplacePricePriceTieredWithProrationConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -16099,10 +13572,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceTieredWithProrationConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override ReplacePricePriceTieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16167,16 +13640,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( - element - ); + return new ReplacePricePriceTieredWithProrationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, + ReplacePricePriceTieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -16186,46 +13657,40 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationFromRaw + ReplacePricePriceGroupedWithMinMaxThresholds, + ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw >) )] -public sealed record class ReplacePricePriceCumulativeGroupedAllocation : JsonModel +public sealed record class ReplacePricePriceGroupedWithMinMaxThresholds : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCadence - > + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } } /// - /// Configuration for cumulative_grouped_allocation pricing + /// Configuration for grouped_with_min_max_thresholds pricing /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "cumulative_grouped_allocation_config" + return this._rawData.GetNotNullClass( + "grouped_with_min_max_thresholds_config" ); } - init { this._rawData.Set("cumulative_grouped_allocation_config", value); } + init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } } /// @@ -16326,12 +13791,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -16461,12 +13926,12 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.CumulativeGroupedAllocationConfig.Validate(); + this.GroupedWithMinMaxThresholdsConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") ) ) { @@ -16488,35 +13953,35 @@ public override void Validate() _ = this.ReferenceID; } - public ReplacePricePriceCumulativeGroupedAllocation() + public ReplacePricePriceGroupedWithMinMaxThresholds() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } - public ReplacePricePriceCumulativeGroupedAllocation( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation replacePricePriceCumulativeGroupedAllocation + public ReplacePricePriceGroupedWithMinMaxThresholds( + ReplacePricePriceGroupedWithMinMaxThresholds replacePricePriceGroupedWithMinMaxThresholds ) - : base(replacePricePriceCumulativeGroupedAllocation) { } + : base(replacePricePriceGroupedWithMinMaxThresholds) { } - public ReplacePricePriceCumulativeGroupedAllocation( + public ReplacePricePriceGroupedWithMinMaxThresholds( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocation(FrozenDictionary rawData) + ReplacePricePriceGroupedWithMinMaxThresholds(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16524,25 +13989,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceCumulativeGroupedAllocationFromRaw - : IFromRawJson +class ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + public ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked( - rawData - ); + ) => ReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCadenceConverter) -)] -public enum ReplacePricePriceCumulativeGroupedAllocationCadence +[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter))] +public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence { Annual, SemiAnnual, @@ -16552,10 +14012,10 @@ public enum ReplacePricePriceCumulativeGroupedAllocationCadence Custom, } -sealed class ReplacePricePriceCumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCadence Read( + public override ReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16563,52 +14023,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceCumulativeGroupedAllocationCadence - .Annual, - "semi_annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceCumulativeGroupedAllocationCadence - .SemiAnnual, - "monthly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceCumulativeGroupedAllocationCadence - .Monthly, - "quarterly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceCumulativeGroupedAllocationCadence - .Quarterly, - "one_time" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceCumulativeGroupedAllocationCadence - .OneTime, - "custom" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceCumulativeGroupedAllocationCadence - .Custom, - _ => - (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCadence)( - -1 - ), + "annual" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + "semi_annual" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual, + "monthly" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly, + "one_time" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime, + "custom" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom, + _ => (ReplacePricePriceGroupedWithMinMaxThresholdsCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCadence value, + ReplacePricePriceGroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -16616,42 +14043,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceCumulativeGroupedAllocationCadence - .Annual => "annual", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceCumulativeGroupedAllocationCadence - .SemiAnnual => "semi_annual", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceCumulativeGroupedAllocationCadence - .Monthly => "monthly", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceCumulativeGroupedAllocationCadence - .Quarterly => "quarterly", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceCumulativeGroupedAllocationCadence - .OneTime => "one_time", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceCumulativeGroupedAllocationCadence - .Custom => "custom", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual => "annual", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly => "monthly", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime => "one_time", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -16662,86 +14059,86 @@ JsonSerializerOptions options } /// -/// Configuration for cumulative_grouped_allocation pricing +/// Configuration for grouped_with_min_max_thresholds pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw >) )] -public sealed record class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig +public sealed record class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig : JsonModel { /// - /// The overall allocation across all groups + /// The event property used to group before applying thresholds /// - public required string CumulativeAllocation + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("cumulative_allocation"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("cumulative_allocation", value); } + init { this._rawData.Set("grouping_key", value); } } /// - /// The allocation per individual group + /// The maximum amount to charge each group /// - public required string GroupAllocation + public required string MaximumCharge { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group_allocation"); + return this._rawData.GetNotNullClass("maximum_charge"); } - init { this._rawData.Set("group_allocation", value); } + init { this._rawData.Set("maximum_charge", value); } } /// - /// The event property used to group usage before applying allocations + /// The minimum amount to charge each group, regardless of usage /// - public required string GroupingKey + public required string MinimumCharge { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("minimum_charge"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("minimum_charge", value); } } /// - /// The amount to charge for each unit outside of the allocation + /// The base price charged per group /// - public required string UnitAmount + public required string PerUnitRate { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullClass("per_unit_rate"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("per_unit_rate", value); } } /// public override void Validate() { - _ = this.CumulativeAllocation; - _ = this.GroupAllocation; _ = this.GroupingKey; - _ = this.UnitAmount; + _ = this.MaximumCharge; + _ = this.MinimumCharge; + _ = this.PerUnitRate; } - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) - : base(replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } + : base(replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData ) { @@ -16750,7 +14147,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -16758,8 +14155,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16767,22 +14164,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( rawData ); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter) -)] -public record class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter))] +public record class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -16799,7 +14194,7 @@ public JsonElement Json } } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16808,7 +14203,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16817,7 +14212,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -16899,7 +14294,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } } @@ -16935,16 +14330,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -16963,14 +14358,14 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? other + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other ) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); @@ -16985,10 +14380,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( + public override ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17053,7 +14448,7 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( element ); } @@ -17062,7 +14457,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -17072,59 +14467,53 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumFromRaw + ReplacePricePriceCumulativeGroupedAllocation, + ReplacePricePriceCumulativeGroupedAllocationFromRaw >) )] -public sealed record class ReplacePricePriceMinimum : JsonModel +public sealed record class ReplacePricePriceCumulativeGroupedAllocation : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence - > + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } } /// - /// The id of the item the price will be associated with. + /// Configuration for cumulative_grouped_allocation pricing /// - public required string ItemID + public required ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass( + "cumulative_grouped_allocation_config" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("cumulative_grouped_allocation_config", value); } } /// - /// Configuration for minimum pricing + /// The id of the item the price will be associated with. /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfig MinimumConfig + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" - ); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("minimum_config", value); } + init { this._rawData.Set("item_id", value); } } /// @@ -17212,12 +14601,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig? ConversionRateConfig + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -17347,9 +14736,14 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); + this.CumulativeGroupedAllocationConfig.Validate(); _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -17369,33 +14763,35 @@ public override void Validate() _ = this.ReferenceID; } - public ReplacePricePriceMinimum() + public ReplacePricePriceCumulativeGroupedAllocation() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public ReplacePricePriceMinimum( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum replacePricePriceMinimum + public ReplacePricePriceCumulativeGroupedAllocation( + ReplacePricePriceCumulativeGroupedAllocation replacePricePriceCumulativeGroupedAllocation ) - : base(replacePricePriceMinimum) { } + : base(replacePricePriceCumulativeGroupedAllocation) { } - public ReplacePricePriceMinimum(IReadOnlyDictionary rawData) + public ReplacePricePriceCumulativeGroupedAllocation( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceMinimum(FrozenDictionary rawData) + ReplacePricePriceCumulativeGroupedAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum FromRawUnchecked( + /// + public static ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17403,22 +14799,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceMinimumFromRaw - : IFromRawJson +class ReplacePricePriceCumulativeGroupedAllocationFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum FromRawUnchecked( + public ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum.FromRawUnchecked(rawData); + ) => ReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadenceConverter) -)] -public enum ReplacePricePriceMinimumCadence +[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationCadenceConverter))] +public enum ReplacePricePriceCumulativeGroupedAllocationCadence { Annual, SemiAnnual, @@ -17428,10 +14822,10 @@ public enum ReplacePricePriceMinimumCadence Custom, } -sealed class ReplacePricePriceMinimumCadenceConverter - : JsonConverter +sealed class ReplacePricePriceCumulativeGroupedAllocationCadenceConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence Read( + public override ReplacePricePriceCumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17439,49 +14833,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceMinimumCadence - .Annual, - "semi_annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceMinimumCadence - .SemiAnnual, - "monthly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceMinimumCadence - .Monthly, - "quarterly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceMinimumCadence - .Quarterly, - "one_time" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceMinimumCadence - .OneTime, - "custom" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceMinimumCadence - .Custom, - _ => (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence)(-1), + "annual" => ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + "semi_annual" => ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly, + "quarterly" => ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly, + "one_time" => ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime, + "custom" => ReplacePricePriceCumulativeGroupedAllocationCadence.Custom, + _ => (ReplacePricePriceCumulativeGroupedAllocationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence value, + ReplacePricePriceCumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -17489,18 +14853,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence.Annual => - "annual", - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence.SemiAnnual => - "semi_annual", - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence.Monthly => - "monthly", - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence.Quarterly => - "quarterly", - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence.OneTime => - "one_time", - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence.Custom => - "custom", + ReplacePricePriceCumulativeGroupedAllocationCadence.Annual => "annual", + ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", + ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly => "monthly", + ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly => "quarterly", + ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime => "one_time", + ReplacePricePriceCumulativeGroupedAllocationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -17511,109 +14869,125 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for cumulative_grouped_allocation pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfig, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfigFromRaw + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw >) )] -public sealed record class ReplacePricePriceMinimumMinimumConfig : JsonModel +public sealed record class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + : JsonModel { /// - /// The minimum amount to apply + /// The overall allocation across all groups /// - public required string MinimumAmount + public required string CumulativeAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNotNullClass("cumulative_allocation"); } - init { this._rawData.Set("minimum_amount", value); } + init { this._rawData.Set("cumulative_allocation", value); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// The allocation per individual group /// - public bool? Prorated + public required string GroupAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); + return this._rawData.GetNotNullClass("group_allocation"); } - init + init { this._rawData.Set("group_allocation", value); } + } + + /// + /// The event property used to group usage before applying allocations + /// + public required string GroupingKey + { + get { - if (value == null) - { - return; - } + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } - this._rawData.Set("prorated", value); + /// + /// The amount to charge for each unit outside of the allocation + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); } + init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.MinimumAmount; - _ = this.Prorated; + _ = this.CumulativeAllocation; + _ = this.GroupAllocation; + _ = this.GroupingKey; + _ = this.UnitAmount; } - public ReplacePricePriceMinimumMinimumConfig() { } + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } - public ReplacePricePriceMinimumMinimumConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfig replacePricePriceMinimumMinimumConfig + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) - : base(replacePricePriceMinimumMinimumConfig) { } + : base(replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } - public ReplacePricePriceMinimumMinimumConfig(IReadOnlyDictionary rawData) + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceMinimumMinimumConfig(FrozenDictionary rawData) + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + /// + public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public ReplacePricePriceMinimumMinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class ReplacePricePriceMinimumMinimumConfigFromRaw - : IFromRawJson +class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfig.FromRawUnchecked( + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( rawData ); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfigConverter) -)] -public record class ReplacePricePriceMinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter))] +public record class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -17630,7 +15004,7 @@ public JsonElement Json } } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17639,7 +15013,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -17648,7 +15022,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig(JsonElement element) + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -17730,7 +15104,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ); } } @@ -17766,16 +15140,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig( + public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig( + public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -17794,14 +15168,14 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig? other + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? other ) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); @@ -17816,10 +15190,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class ReplacePricePriceMinimumConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig? Read( + public override ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17884,7 +15258,7 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig( + return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( element ); } @@ -17893,7 +15267,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig value, + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -17902,30 +15276,21 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class ReplacePricePricePercent : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentCadence - > - >("cadence"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } init { this._rawData.Set("cadence", value); } } @@ -17972,12 +15337,12 @@ public required string Name /// /// Configuration for percent pricing /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentPercentConfig PercentConfig + public required ReplacePricePricePercentPercentConfig PercentConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "percent_config" ); } @@ -18043,12 +15408,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentConversionRateConfig? ConversionRateConfig + public ReplacePricePricePercentConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -18205,9 +15570,7 @@ public ReplacePricePricePercent() this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public ReplacePricePricePercent( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent replacePricePricePercent - ) + public ReplacePricePricePercent(ReplacePricePricePercent replacePricePricePercent) : base(replacePricePricePercent) { } public ReplacePricePricePercent(IReadOnlyDictionary rawData) @@ -18225,8 +15588,8 @@ public ReplacePricePricePercent(IReadOnlyDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent FromRawUnchecked( + /// + public static ReplacePricePricePercent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -18234,21 +15597,18 @@ IReadOnlyDictionary rawData } } -class ReplacePricePricePercentFromRaw - : IFromRawJson +class ReplacePricePricePercentFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent FromRawUnchecked( + public ReplacePricePricePercent FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent.FromRawUnchecked(rawData); + ) => ReplacePricePricePercent.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentCadenceConverter) -)] +[JsonConverter(typeof(ReplacePricePricePercentCadenceConverter))] public enum ReplacePricePricePercentCadence { Annual, @@ -18260,9 +15620,9 @@ public enum ReplacePricePricePercentCadence } sealed class ReplacePricePricePercentCadenceConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentCadence Read( + public override ReplacePricePricePercentCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -18270,49 +15630,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePricePercentCadence - .Annual, - "semi_annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePricePercentCadence - .SemiAnnual, - "monthly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePricePercentCadence - .Monthly, - "quarterly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePricePercentCadence - .Quarterly, - "one_time" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePricePercentCadence - .OneTime, - "custom" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePricePercentCadence - .Custom, - _ => (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentCadence)(-1), + "annual" => ReplacePricePricePercentCadence.Annual, + "semi_annual" => ReplacePricePricePercentCadence.SemiAnnual, + "monthly" => ReplacePricePricePercentCadence.Monthly, + "quarterly" => ReplacePricePricePercentCadence.Quarterly, + "one_time" => ReplacePricePricePercentCadence.OneTime, + "custom" => ReplacePricePricePercentCadence.Custom, + _ => (ReplacePricePricePercentCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentCadence value, + ReplacePricePricePercentCadence value, JsonSerializerOptions options ) { @@ -18320,18 +15650,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentCadence.Annual => - "annual", - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentCadence.SemiAnnual => - "semi_annual", - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentCadence.Monthly => - "monthly", - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentCadence.Quarterly => - "quarterly", - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentCadence.OneTime => - "one_time", - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentCadence.Custom => - "custom", + ReplacePricePricePercentCadence.Annual => "annual", + ReplacePricePricePercentCadence.SemiAnnual => "semi_annual", + ReplacePricePricePercentCadence.Monthly => "monthly", + ReplacePricePricePercentCadence.Quarterly => "quarterly", + ReplacePricePricePercentCadence.OneTime => "one_time", + ReplacePricePricePercentCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -18346,8 +15670,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentPercentConfig, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentPercentConfigFromRaw + ReplacePricePricePercentPercentConfig, + ReplacePricePricePercentPercentConfigFromRaw >) )] public sealed record class ReplacePricePricePercentPercentConfig : JsonModel @@ -18374,7 +15698,7 @@ public override void Validate() public ReplacePricePricePercentPercentConfig() { } public ReplacePricePricePercentPercentConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentPercentConfig replacePricePricePercentPercentConfig + ReplacePricePricePercentPercentConfig replacePricePricePercentPercentConfig ) : base(replacePricePricePercentPercentConfig) { } @@ -18391,8 +15715,8 @@ public ReplacePricePricePercentPercentConfig(IReadOnlyDictionary - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentPercentConfig FromRawUnchecked( + /// + public static ReplacePricePricePercentPercentConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -18408,20 +15732,15 @@ public ReplacePricePricePercentPercentConfig(double percent) } class ReplacePricePricePercentPercentConfigFromRaw - : IFromRawJson + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentPercentConfig FromRawUnchecked( + public ReplacePricePricePercentPercentConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentPercentConfig.FromRawUnchecked( - rawData - ); + ) => ReplacePricePricePercentPercentConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentConversionRateConfigConverter) -)] +[JsonConverter(typeof(ReplacePricePricePercentConversionRateConfigConverter))] public record class ReplacePricePricePercentConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -18580,11 +15899,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentConversionRateConfig( + public static implicit operator ReplacePricePricePercentConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentConversionRateConfig( + public static implicit operator ReplacePricePricePercentConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -18609,9 +15928,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentConversionRateConfig? other - ) + public virtual bool Equals(ReplacePricePricePercentConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -18626,9 +15943,9 @@ public override string ToString() => } sealed class ReplacePricePricePercentConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentConversionRateConfig? Read( + public override ReplacePricePricePercentConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -18693,16 +16010,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentConversionRateConfig( - element - ); + return new ReplacePricePricePercentConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentConversionRateConfig value, + ReplacePricePricePercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -18711,29 +16026,20 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class ReplacePricePriceEventOutput : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputCadence - > + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -18742,12 +16048,12 @@ public required ApiEnum< /// /// Configuration for event_output pricing /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputEventOutputConfig EventOutputConfig + public required ReplacePricePriceEventOutputEventOutputConfig EventOutputConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "event_output_config" ); } @@ -18852,12 +16158,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputConversionRateConfig? ConversionRateConfig + public ReplacePricePriceEventOutputConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -19019,9 +16325,7 @@ public ReplacePricePriceEventOutput() this.ModelType = JsonSerializer.SerializeToElement("event_output"); } - public ReplacePricePriceEventOutput( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput replacePricePriceEventOutput - ) + public ReplacePricePriceEventOutput(ReplacePricePriceEventOutput replacePricePriceEventOutput) : base(replacePricePriceEventOutput) { } public ReplacePricePriceEventOutput(IReadOnlyDictionary rawData) @@ -19039,8 +16343,8 @@ public ReplacePricePriceEventOutput(IReadOnlyDictionary raw } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput FromRawUnchecked( + /// + public static ReplacePricePriceEventOutput FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -19048,24 +16352,18 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceEventOutputFromRaw - : IFromRawJson +class ReplacePricePriceEventOutputFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput FromRawUnchecked( + public ReplacePricePriceEventOutput FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput.FromRawUnchecked( - rawData - ); + ) => ReplacePricePriceEventOutput.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputCadenceConverter) -)] +[JsonConverter(typeof(ReplacePricePriceEventOutputCadenceConverter))] public enum ReplacePricePriceEventOutputCadence { Annual, @@ -19077,9 +16375,9 @@ public enum ReplacePricePriceEventOutputCadence } sealed class ReplacePricePriceEventOutputCadenceConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputCadence Read( + public override ReplacePricePriceEventOutputCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -19087,49 +16385,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceEventOutputCadence - .Annual, - "semi_annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceEventOutputCadence - .SemiAnnual, - "monthly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceEventOutputCadence - .Monthly, - "quarterly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceEventOutputCadence - .Quarterly, - "one_time" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceEventOutputCadence - .OneTime, - "custom" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceEventOutputCadence - .Custom, - _ => (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputCadence)(-1), + "annual" => ReplacePricePriceEventOutputCadence.Annual, + "semi_annual" => ReplacePricePriceEventOutputCadence.SemiAnnual, + "monthly" => ReplacePricePriceEventOutputCadence.Monthly, + "quarterly" => ReplacePricePriceEventOutputCadence.Quarterly, + "one_time" => ReplacePricePriceEventOutputCadence.OneTime, + "custom" => ReplacePricePriceEventOutputCadence.Custom, + _ => (ReplacePricePriceEventOutputCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputCadence value, + ReplacePricePriceEventOutputCadence value, JsonSerializerOptions options ) { @@ -19137,34 +16405,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputCadence.Annual => - "annual", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceEventOutputCadence - .SemiAnnual => "semi_annual", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceEventOutputCadence - .Monthly => "monthly", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceEventOutputCadence - .Quarterly => "quarterly", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceEventOutputCadence - .OneTime => "one_time", - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputCadence.Custom => - "custom", + ReplacePricePriceEventOutputCadence.Annual => "annual", + ReplacePricePriceEventOutputCadence.SemiAnnual => "semi_annual", + ReplacePricePriceEventOutputCadence.Monthly => "monthly", + ReplacePricePriceEventOutputCadence.Quarterly => "quarterly", + ReplacePricePriceEventOutputCadence.OneTime => "one_time", + ReplacePricePriceEventOutputCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -19179,8 +16425,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputEventOutputConfig, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputEventOutputConfigFromRaw + ReplacePricePriceEventOutputEventOutputConfig, + ReplacePricePriceEventOutputEventOutputConfigFromRaw >) )] public sealed record class ReplacePricePriceEventOutputEventOutputConfig : JsonModel @@ -19238,7 +16484,7 @@ public override void Validate() public ReplacePricePriceEventOutputEventOutputConfig() { } public ReplacePricePriceEventOutputEventOutputConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputEventOutputConfig replacePricePriceEventOutputEventOutputConfig + ReplacePricePriceEventOutputEventOutputConfig replacePricePriceEventOutputEventOutputConfig ) : base(replacePricePriceEventOutputEventOutputConfig) { } @@ -19257,8 +16503,8 @@ IReadOnlyDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputEventOutputConfig FromRawUnchecked( + /// + public static ReplacePricePriceEventOutputEventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -19274,20 +16520,15 @@ public ReplacePricePriceEventOutputEventOutputConfig(string unitRatingKey) } class ReplacePricePriceEventOutputEventOutputConfigFromRaw - : IFromRawJson + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputEventOutputConfig FromRawUnchecked( + public ReplacePricePriceEventOutputEventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputEventOutputConfig.FromRawUnchecked( - rawData - ); + ) => ReplacePricePriceEventOutputEventOutputConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputConversionRateConfigConverter) -)] +[JsonConverter(typeof(ReplacePricePriceEventOutputConversionRateConfigConverter))] public record class ReplacePricePriceEventOutputConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -19446,11 +16687,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputConversionRateConfig( + public static implicit operator ReplacePricePriceEventOutputConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputConversionRateConfig( + public static implicit operator ReplacePricePriceEventOutputConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -19475,9 +16716,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputConversionRateConfig? other - ) + public virtual bool Equals(ReplacePricePriceEventOutputConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -19492,9 +16731,9 @@ public override string ToString() => } sealed class ReplacePricePriceEventOutputConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputConversionRateConfig? Read( + public override ReplacePricePriceEventOutputConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -19559,16 +16798,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputConversionRateConfig( - element - ); + return new ReplacePricePriceEventOutputConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputConversionRateConfig value, + ReplacePricePriceEventOutputConversionRateConfig value, JsonSerializerOptions options ) { diff --git a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDFetchPlanVersionParams.cs b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDFetchPlanVersionParams.cs index be2e0796..dc561588 100644 --- a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDFetchPlanVersionParams.cs +++ b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDFetchPlanVersionParams.cs @@ -11,8 +11,12 @@ namespace Orb.Models.Beta.ExternalPlanID; /// /// This endpoint is used to fetch a plan version. It returns the phases, prices, /// and adjustments present on this version of the plan. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ExternalPlanIDFetchPlanVersionParams : ParamsBase +public record class ExternalPlanIDFetchPlanVersionParams : ParamsBase { public required string ExternalPlanID { get; init; } @@ -20,6 +24,8 @@ public sealed record class ExternalPlanIDFetchPlanVersionParams : ParamsBase public ExternalPlanIDFetchPlanVersionParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ExternalPlanIDFetchPlanVersionParams( ExternalPlanIDFetchPlanVersionParams externalPlanIDFetchPlanVersionParams ) @@ -28,6 +34,7 @@ ExternalPlanIDFetchPlanVersionParams externalPlanIDFetchPlanVersionParams this.ExternalPlanID = externalPlanIDFetchPlanVersionParams.ExternalPlanID; this.Version = externalPlanIDFetchPlanVersionParams.Version; } +#pragma warning restore CS8618 public ExternalPlanIDFetchPlanVersionParams( IReadOnlyDictionary rawHeaderData, @@ -62,6 +69,30 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ExternalPlanID"] = this.ExternalPlanID, + ["Version"] = this.Version, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ExternalPlanIDFetchPlanVersionParams? other) + { + if (other == null) + { + return false; + } + return this.ExternalPlanID.Equals(other.ExternalPlanID) + && (this.Version?.Equals(other.Version) ?? other.Version == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -85,4 +116,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDSetDefaultPlanVersionParams.cs b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDSetDefaultPlanVersionParams.cs index 48f536f0..8f7fe53e 100644 --- a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDSetDefaultPlanVersionParams.cs +++ b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDSetDefaultPlanVersionParams.cs @@ -11,8 +11,12 @@ namespace Orb.Models.Beta.ExternalPlanID; /// /// This endpoint allows setting the default version of a plan. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ExternalPlanIDSetDefaultPlanVersionParams : ParamsBase +public record class ExternalPlanIDSetDefaultPlanVersionParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -37,6 +41,8 @@ public required long Version public ExternalPlanIDSetDefaultPlanVersionParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ExternalPlanIDSetDefaultPlanVersionParams( ExternalPlanIDSetDefaultPlanVersionParams externalPlanIDSetDefaultPlanVersionParams ) @@ -46,6 +52,7 @@ ExternalPlanIDSetDefaultPlanVersionParams externalPlanIDSetDefaultPlanVersionPar this._rawBodyData = new(externalPlanIDSetDefaultPlanVersionParams._rawBodyData); } +#pragma warning restore CS8618 public ExternalPlanIDSetDefaultPlanVersionParams( IReadOnlyDictionary rawHeaderData, @@ -86,6 +93,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ExternalPlanID"] = this.ExternalPlanID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ExternalPlanIDSetDefaultPlanVersionParams? other) + { + if (other == null) + { + return false; + } + return (this.ExternalPlanID?.Equals(other.ExternalPlanID) ?? other.ExternalPlanID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -117,4 +148,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Beta/PlanVersionPhase.cs b/src/Orb/Models/Beta/PlanVersionPhase.cs index c31e3cce..b988baf9 100644 --- a/src/Orb/Models/Beta/PlanVersionPhase.cs +++ b/src/Orb/Models/Beta/PlanVersionPhase.cs @@ -46,14 +46,12 @@ public required long? Duration init { this._rawData.Set("duration", value); } } - public required ApiEnum? DurationUnit + public required ApiEnum? DurationUnit { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass< - ApiEnum - >("duration_unit"); + return this._rawData.GetNullableClass>("duration_unit"); } init { this._rawData.Set("duration_unit", value); } } @@ -126,7 +124,7 @@ public PlanVersionPhase FromRawUnchecked(IReadOnlyDictionary +sealed class DurationUnitConverter : JsonConverter { - public override global::Orb.Models.Beta.DurationUnit Read( + public override DurationUnit Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -146,18 +144,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "daily" => global::Orb.Models.Beta.DurationUnit.Daily, - "monthly" => global::Orb.Models.Beta.DurationUnit.Monthly, - "quarterly" => global::Orb.Models.Beta.DurationUnit.Quarterly, - "semi_annual" => global::Orb.Models.Beta.DurationUnit.SemiAnnual, - "annual" => global::Orb.Models.Beta.DurationUnit.Annual, - _ => (global::Orb.Models.Beta.DurationUnit)(-1), + "daily" => DurationUnit.Daily, + "monthly" => DurationUnit.Monthly, + "quarterly" => DurationUnit.Quarterly, + "semi_annual" => DurationUnit.SemiAnnual, + "annual" => DurationUnit.Annual, + _ => (DurationUnit)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.DurationUnit value, + DurationUnit value, JsonSerializerOptions options ) { @@ -165,11 +163,11 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Beta.DurationUnit.Daily => "daily", - global::Orb.Models.Beta.DurationUnit.Monthly => "monthly", - global::Orb.Models.Beta.DurationUnit.Quarterly => "quarterly", - global::Orb.Models.Beta.DurationUnit.SemiAnnual => "semi_annual", - global::Orb.Models.Beta.DurationUnit.Annual => "annual", + DurationUnit.Daily => "daily", + DurationUnit.Monthly => "monthly", + DurationUnit.Quarterly => "quarterly", + DurationUnit.SemiAnnual => "semi_annual", + DurationUnit.Annual => "annual", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Coupons/CouponArchiveParams.cs b/src/Orb/Models/Coupons/CouponArchiveParams.cs index c952ddf5..a54235c4 100644 --- a/src/Orb/Models/Coupons/CouponArchiveParams.cs +++ b/src/Orb/Models/Coupons/CouponArchiveParams.cs @@ -12,18 +12,25 @@ namespace Orb.Models.Coupons; /// This endpoint allows a coupon to be archived. Archived coupons can no longer be /// redeemed, and will be hidden from lists of active coupons. Additionally, once /// a coupon is archived, its redemption code can be reused for a different coupon. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CouponArchiveParams : ParamsBase +public record class CouponArchiveParams : ParamsBase { public string? CouponID { get; init; } public CouponArchiveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CouponArchiveParams(CouponArchiveParams couponArchiveParams) : base(couponArchiveParams) { this.CouponID = couponArchiveParams.CouponID; } +#pragma warning restore CS8618 public CouponArchiveParams( IReadOnlyDictionary rawHeaderData, @@ -58,6 +65,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["CouponID"] = this.CouponID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CouponArchiveParams? other) + { + if (other == null) + { + return false; + } + return (this.CouponID?.Equals(other.CouponID) ?? other.CouponID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -77,4 +106,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Coupons/CouponCreateParams.cs b/src/Orb/Models/Coupons/CouponCreateParams.cs index 036e75ba..dd7f7677 100644 --- a/src/Orb/Models/Coupons/CouponCreateParams.cs +++ b/src/Orb/Models/Coupons/CouponCreateParams.cs @@ -14,8 +14,12 @@ namespace Orb.Models.Coupons; /// /// This endpoint allows the creation of coupons, which can then be redeemed at subscription /// creation or plan change. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CouponCreateParams : ParamsBase +public record class CouponCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -23,14 +27,12 @@ public IReadOnlyDictionary RawBodyData get { return this._rawBodyData.Freeze(); } } - public required global::Orb.Models.Coupons.Discount Discount + public required Discount Discount { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNotNullClass( - "discount" - ); + return this._rawBodyData.GetNotNullClass("discount"); } init { this._rawBodyData.Set("discount", value); } } @@ -78,11 +80,14 @@ public long? MaxRedemptions public CouponCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CouponCreateParams(CouponCreateParams couponCreateParams) : base(couponCreateParams) { this._rawBodyData = new(couponCreateParams._rawBodyData); } +#pragma warning restore CS8618 public CouponCreateParams( IReadOnlyDictionary rawHeaderData, @@ -123,6 +128,28 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CouponCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/coupons") @@ -148,6 +175,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(DiscountConverter))] @@ -298,10 +330,9 @@ public T Match(System::Func percentage, System::Func - new(value); + public static implicit operator Discount(Percentage value) => new(value); - public static implicit operator global::Orb.Models.Coupons.Discount(Amount value) => new(value); + public static implicit operator Discount(Amount value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -322,7 +353,7 @@ public override void Validate() this.Switch((percentage) => percentage.Validate(), (amount) => amount.Validate()); } - public virtual bool Equals(global::Orb.Models.Coupons.Discount? other) + public virtual bool Equals(Discount? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -336,9 +367,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class DiscountConverter : JsonConverter +sealed class DiscountConverter : JsonConverter { - public override global::Orb.Models.Coupons.Discount? Read( + public override Discount? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -397,16 +428,12 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Coupons.Discount(element); + return new Discount(element); } } } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Coupons.Discount value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Discount value, JsonSerializerOptions options) { JsonSerializer.Serialize(writer, value.Json, options); } diff --git a/src/Orb/Models/Coupons/CouponFetchParams.cs b/src/Orb/Models/Coupons/CouponFetchParams.cs index bd33502d..f7317219 100644 --- a/src/Orb/Models/Coupons/CouponFetchParams.cs +++ b/src/Orb/Models/Coupons/CouponFetchParams.cs @@ -11,18 +11,25 @@ namespace Orb.Models.Coupons; /// /// This endpoint retrieves a coupon by its ID. To fetch coupons by their redemption /// code, use the [List coupons](list-coupons) endpoint with the redemption_code parameter. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CouponFetchParams : ParamsBase +public record class CouponFetchParams : ParamsBase { public string? CouponID { get; init; } public CouponFetchParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CouponFetchParams(CouponFetchParams couponFetchParams) : base(couponFetchParams) { this.CouponID = couponFetchParams.CouponID; } +#pragma warning restore CS8618 public CouponFetchParams( IReadOnlyDictionary rawHeaderData, @@ -57,6 +64,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["CouponID"] = this.CouponID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CouponFetchParams? other) + { + if (other == null) + { + return false; + } + return (this.CouponID?.Equals(other.CouponID) ?? other.CouponID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -75,4 +104,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Coupons/CouponListParams.cs b/src/Orb/Models/Coupons/CouponListParams.cs index 08ed5b23..f01453c5 100644 --- a/src/Orb/Models/Coupons/CouponListParams.cs +++ b/src/Orb/Models/Coupons/CouponListParams.cs @@ -15,8 +15,12 @@ namespace Orb.Models.Coupons; /// coupon. The response also includes `pagination_metadata`, which lets the caller /// retrieve the next page of results if they exist. More information about pagination /// can be found in the Pagination-metadata schema. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CouponListParams : ParamsBase +public record class CouponListParams : ParamsBase { /// /// Cursor for pagination. This can be populated by the `next_cursor` value returned @@ -81,8 +85,11 @@ public bool? ShowArchived public CouponListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CouponListParams(CouponListParams couponListParams) : base(couponListParams) { } +#pragma warning restore CS8618 public CouponListParams( IReadOnlyDictionary rawHeaderData, @@ -117,6 +124,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CouponListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/coupons") @@ -133,4 +160,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Coupons/Subscriptions/SubscriptionListParams.cs b/src/Orb/Models/Coupons/Subscriptions/SubscriptionListParams.cs index aa9f3573..c527cbaa 100644 --- a/src/Orb/Models/Coupons/Subscriptions/SubscriptionListParams.cs +++ b/src/Orb/Models/Coupons/Subscriptions/SubscriptionListParams.cs @@ -13,8 +13,12 @@ namespace Orb.Models.Coupons.Subscriptions; /// as a [paginated](/api-reference/pagination) list, ordered starting from the most /// recently created subscription. For a full discussion of the subscription resource, /// see [Subscription](/core-concepts#subscription). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionListParams : ParamsBase +public record class SubscriptionListParams : ParamsBase { public string? CouponID { get; init; } @@ -55,11 +59,14 @@ public long? Limit public SubscriptionListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionListParams(SubscriptionListParams subscriptionListParams) : base(subscriptionListParams) { this.CouponID = subscriptionListParams.CouponID; } +#pragma warning restore CS8618 public SubscriptionListParams( IReadOnlyDictionary rawHeaderData, @@ -94,6 +101,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["CouponID"] = this.CouponID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionListParams? other) + { + if (other == null) + { + return false; + } + return (this.CouponID?.Equals(other.CouponID) ?? other.CouponID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -113,4 +142,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/CreditBlocks/CreditBlockDeleteParams.cs b/src/Orb/Models/CreditBlocks/CreditBlockDeleteParams.cs index 1969fb28..3a66a99a 100644 --- a/src/Orb/Models/CreditBlocks/CreditBlockDeleteParams.cs +++ b/src/Orb/Models/CreditBlocks/CreditBlockDeleteParams.cs @@ -20,18 +20,25 @@ namespace Orb.Models.CreditBlocks; /// Issued invoices that had credits applied from this block will not /// be regenerated, but the ledger will reflect the state as if credits from the /// deleted block were never applied. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CreditBlockDeleteParams : ParamsBase +public record class CreditBlockDeleteParams : ParamsBase { public string? BlockID { get; init; } public CreditBlockDeleteParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditBlockDeleteParams(CreditBlockDeleteParams creditBlockDeleteParams) : base(creditBlockDeleteParams) { this.BlockID = creditBlockDeleteParams.BlockID; } +#pragma warning restore CS8618 public CreditBlockDeleteParams( IReadOnlyDictionary rawHeaderData, @@ -66,6 +73,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["BlockID"] = this.BlockID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CreditBlockDeleteParams? other) + { + if (other == null) + { + return false; + } + return (this.BlockID?.Equals(other.BlockID) ?? other.BlockID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -85,4 +114,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/CreditBlocks/CreditBlockRetrieveParams.cs b/src/Orb/Models/CreditBlocks/CreditBlockRetrieveParams.cs index 2754063d..0eda4b9f 100644 --- a/src/Orb/Models/CreditBlocks/CreditBlockRetrieveParams.cs +++ b/src/Orb/Models/CreditBlocks/CreditBlockRetrieveParams.cs @@ -10,18 +10,25 @@ namespace Orb.Models.CreditBlocks; /// /// This endpoint returns a credit block identified by its block_id. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CreditBlockRetrieveParams : ParamsBase +public record class CreditBlockRetrieveParams : ParamsBase { public string? BlockID { get; init; } public CreditBlockRetrieveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditBlockRetrieveParams(CreditBlockRetrieveParams creditBlockRetrieveParams) : base(creditBlockRetrieveParams) { this.BlockID = creditBlockRetrieveParams.BlockID; } +#pragma warning restore CS8618 public CreditBlockRetrieveParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["BlockID"] = this.BlockID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CreditBlockRetrieveParams? other) + { + if (other == null) + { + return false; + } + return (this.BlockID?.Equals(other.BlockID) ?? other.BlockID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -75,4 +104,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/CreditBlocks/CreditBlockRetrieveResponse.cs b/src/Orb/Models/CreditBlocks/CreditBlockRetrieveResponse.cs index 473a89a0..a8c8534a 100644 --- a/src/Orb/Models/CreditBlocks/CreditBlockRetrieveResponse.cs +++ b/src/Orb/Models/CreditBlocks/CreditBlockRetrieveResponse.cs @@ -58,18 +58,16 @@ public required double Balance init { this._rawData.Set("expiry_date", value); } } - public required IReadOnlyList Filters + public required IReadOnlyList Filters { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("filters"); + return this._rawData.GetNotNullStruct>("filters"); } init { - this._rawData.Set>( + this._rawData.Set>( "filters", ImmutableArray.ToImmutableArray(value) ); @@ -96,14 +94,12 @@ public required string? PerUnitCostBasis init { this._rawData.Set("per_unit_cost_basis", value); } } - public required ApiEnum Status + public required ApiEnum Status { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("status"); + return this._rawData.GetNotNullClass>("status"); } init { this._rawData.Set("status", value); } } @@ -159,25 +155,18 @@ IReadOnlyDictionary rawData ) => CreditBlockRetrieveResponse.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.CreditBlocks.Filter, - global::Orb.Models.CreditBlocks.FilterFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Filter : JsonModel { /// /// The property of the price to filter on. /// - public required ApiEnum Field + public required ApiEnum Field { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("field"); + return this._rawData.GetNotNullClass>("field"); } init { this._rawData.Set("field", value); } } @@ -185,14 +174,12 @@ public sealed record class Filter : JsonModel /// /// Should prices that match the filter be included or excluded. /// - public required ApiEnum Operator + public required ApiEnum Operator { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("operator"); + return this._rawData.GetNotNullClass>("operator"); } init { this._rawData.Set("operator", value); } } @@ -226,7 +213,7 @@ public override void Validate() public Filter() { } - public Filter(global::Orb.Models.CreditBlocks.Filter filter) + public Filter(Filter filter) : base(filter) { } public Filter(IReadOnlyDictionary rawData) @@ -242,27 +229,24 @@ public Filter(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.CreditBlocks.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Filter FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class FilterFromRaw : IFromRawJson +class FilterFromRaw : IFromRawJson { /// - public global::Orb.Models.CreditBlocks.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.CreditBlocks.Filter.FromRawUnchecked(rawData); + public Filter FromRawUnchecked(IReadOnlyDictionary rawData) => + Filter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(global::Orb.Models.CreditBlocks.FieldConverter))] +[JsonConverter(typeof(FieldConverter))] public enum Field { PriceID, @@ -272,9 +256,9 @@ public enum Field PricingUnitID, } -sealed class FieldConverter : JsonConverter +sealed class FieldConverter : JsonConverter { - public override global::Orb.Models.CreditBlocks.Field Read( + public override Field Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -282,30 +266,26 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "price_id" => global::Orb.Models.CreditBlocks.Field.PriceID, - "item_id" => global::Orb.Models.CreditBlocks.Field.ItemID, - "price_type" => global::Orb.Models.CreditBlocks.Field.PriceType, - "currency" => global::Orb.Models.CreditBlocks.Field.Currency, - "pricing_unit_id" => global::Orb.Models.CreditBlocks.Field.PricingUnitID, - _ => (global::Orb.Models.CreditBlocks.Field)(-1), + "price_id" => Field.PriceID, + "item_id" => Field.ItemID, + "price_type" => Field.PriceType, + "currency" => Field.Currency, + "pricing_unit_id" => Field.PricingUnitID, + _ => (Field)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.CreditBlocks.Field value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Field value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.CreditBlocks.Field.PriceID => "price_id", - global::Orb.Models.CreditBlocks.Field.ItemID => "item_id", - global::Orb.Models.CreditBlocks.Field.PriceType => "price_type", - global::Orb.Models.CreditBlocks.Field.Currency => "currency", - global::Orb.Models.CreditBlocks.Field.PricingUnitID => "pricing_unit_id", + Field.PriceID => "price_id", + Field.ItemID => "item_id", + Field.PriceType => "price_type", + Field.Currency => "currency", + Field.PricingUnitID => "pricing_unit_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -318,16 +298,16 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(global::Orb.Models.CreditBlocks.OperatorConverter))] +[JsonConverter(typeof(OperatorConverter))] public enum Operator { Includes, Excludes, } -sealed class OperatorConverter : JsonConverter +sealed class OperatorConverter : JsonConverter { - public override global::Orb.Models.CreditBlocks.Operator Read( + public override Operator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -335,24 +315,20 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => global::Orb.Models.CreditBlocks.Operator.Includes, - "excludes" => global::Orb.Models.CreditBlocks.Operator.Excludes, - _ => (global::Orb.Models.CreditBlocks.Operator)(-1), + "includes" => Operator.Includes, + "excludes" => Operator.Excludes, + _ => (Operator)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.CreditBlocks.Operator value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Operator value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.CreditBlocks.Operator.Includes => "includes", - global::Orb.Models.CreditBlocks.Operator.Excludes => "excludes", + Operator.Includes => "includes", + Operator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -362,16 +338,16 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.CreditBlocks.StatusConverter))] +[JsonConverter(typeof(StatusConverter))] public enum Status { Active, PendingPayment, } -sealed class StatusConverter : JsonConverter +sealed class StatusConverter : JsonConverter { - public override global::Orb.Models.CreditBlocks.Status Read( + public override Status Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -379,24 +355,20 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "active" => global::Orb.Models.CreditBlocks.Status.Active, - "pending_payment" => global::Orb.Models.CreditBlocks.Status.PendingPayment, - _ => (global::Orb.Models.CreditBlocks.Status)(-1), + "active" => Status.Active, + "pending_payment" => Status.PendingPayment, + _ => (Status)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.CreditBlocks.Status value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.CreditBlocks.Status.Active => "active", - global::Orb.Models.CreditBlocks.Status.PendingPayment => "pending_payment", + Status.Active => "active", + Status.PendingPayment => "pending_payment", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/CreditNotes/CreditNoteCreateParams.cs b/src/Orb/Models/CreditNotes/CreditNoteCreateParams.cs index d77b47d4..74d00a8e 100644 --- a/src/Orb/Models/CreditNotes/CreditNoteCreateParams.cs +++ b/src/Orb/Models/CreditNotes/CreditNoteCreateParams.cs @@ -38,8 +38,12 @@ namespace Orb.Models.CreditNotes; /// Note: Both start_date and end_date are inclusive - the service period will /// cover both the start date and end date completely (from start of start_date to /// end of end_date). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CreditNoteCreateParams : ParamsBase +public record class CreditNoteCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -47,18 +51,16 @@ public IReadOnlyDictionary RawBodyData get { return this._rawBodyData.Freeze(); } } - public required IReadOnlyList LineItems + public required IReadOnlyList LineItems { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNotNullStruct< - ImmutableArray - >("line_items"); + return this._rawBodyData.GetNotNullStruct>("line_items"); } init { - this._rawBodyData.Set>( + this._rawBodyData.Set>( "line_items", ImmutableArray.ToImmutableArray(value) ); @@ -68,14 +70,12 @@ public IReadOnlyDictionary RawBodyData /// /// An optional reason for the credit note. /// - public required ApiEnum Reason + public required ApiEnum Reason { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNotNullClass< - ApiEnum - >("reason"); + return this._rawBodyData.GetNotNullClass>("reason"); } init { this._rawBodyData.Set("reason", value); } } @@ -129,11 +129,14 @@ public string? StartDate public CreditNoteCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditNoteCreateParams(CreditNoteCreateParams creditNoteCreateParams) : base(creditNoteCreateParams) { this._rawBodyData = new(creditNoteCreateParams._rawBodyData); } +#pragma warning restore CS8618 public CreditNoteCreateParams( IReadOnlyDictionary rawHeaderData, @@ -174,6 +177,28 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CreditNoteCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/credit_notes") @@ -199,14 +224,14 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.CreditNotes.LineItem, - global::Orb.Models.CreditNotes.LineItemFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class LineItem : JsonModel { /// @@ -279,7 +304,7 @@ public override void Validate() public LineItem() { } - public LineItem(global::Orb.Models.CreditNotes.LineItem lineItem) + public LineItem(LineItem lineItem) : base(lineItem) { } public LineItem(IReadOnlyDictionary rawData) @@ -295,27 +320,24 @@ public LineItem(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.CreditNotes.LineItem FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static LineItem FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class LineItemFromRaw : IFromRawJson +class LineItemFromRaw : IFromRawJson { /// - public global::Orb.Models.CreditNotes.LineItem FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.CreditNotes.LineItem.FromRawUnchecked(rawData); + public LineItem FromRawUnchecked(IReadOnlyDictionary rawData) => + LineItem.FromRawUnchecked(rawData); } /// /// An optional reason for the credit note. /// -[JsonConverter(typeof(global::Orb.Models.CreditNotes.ReasonConverter))] +[JsonConverter(typeof(ReasonConverter))] public enum Reason { Duplicate, @@ -324,9 +346,9 @@ public enum Reason ProductUnsatisfactory, } -sealed class ReasonConverter : JsonConverter +sealed class ReasonConverter : JsonConverter { - public override global::Orb.Models.CreditNotes.Reason Read( + public override Reason Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -334,29 +356,24 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "duplicate" => global::Orb.Models.CreditNotes.Reason.Duplicate, - "fraudulent" => global::Orb.Models.CreditNotes.Reason.Fraudulent, - "order_change" => global::Orb.Models.CreditNotes.Reason.OrderChange, - "product_unsatisfactory" => global::Orb.Models.CreditNotes.Reason.ProductUnsatisfactory, - _ => (global::Orb.Models.CreditNotes.Reason)(-1), + "duplicate" => Reason.Duplicate, + "fraudulent" => Reason.Fraudulent, + "order_change" => Reason.OrderChange, + "product_unsatisfactory" => Reason.ProductUnsatisfactory, + _ => (Reason)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.CreditNotes.Reason value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Reason value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.CreditNotes.Reason.Duplicate => "duplicate", - global::Orb.Models.CreditNotes.Reason.Fraudulent => "fraudulent", - global::Orb.Models.CreditNotes.Reason.OrderChange => "order_change", - global::Orb.Models.CreditNotes.Reason.ProductUnsatisfactory => - "product_unsatisfactory", + Reason.Duplicate => "duplicate", + Reason.Fraudulent => "fraudulent", + Reason.OrderChange => "order_change", + Reason.ProductUnsatisfactory => "product_unsatisfactory", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/CreditNotes/CreditNoteFetchParams.cs b/src/Orb/Models/CreditNotes/CreditNoteFetchParams.cs index 3ff4c726..8a2eeaa9 100644 --- a/src/Orb/Models/CreditNotes/CreditNoteFetchParams.cs +++ b/src/Orb/Models/CreditNotes/CreditNoteFetchParams.cs @@ -11,18 +11,25 @@ namespace Orb.Models.CreditNotes; /// /// This endpoint is used to fetch a single [`Credit Note`](/invoicing/credit-notes) /// given an identifier. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CreditNoteFetchParams : ParamsBase +public record class CreditNoteFetchParams : ParamsBase { public string? CreditNoteID { get; init; } public CreditNoteFetchParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditNoteFetchParams(CreditNoteFetchParams creditNoteFetchParams) : base(creditNoteFetchParams) { this.CreditNoteID = creditNoteFetchParams.CreditNoteID; } +#pragma warning restore CS8618 public CreditNoteFetchParams( IReadOnlyDictionary rawHeaderData, @@ -57,6 +64,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["CreditNoteID"] = this.CreditNoteID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CreditNoteFetchParams? other) + { + if (other == null) + { + return false; + } + return (this.CreditNoteID?.Equals(other.CreditNoteID) ?? other.CreditNoteID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -76,4 +105,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/CreditNotes/CreditNoteListParams.cs b/src/Orb/Models/CreditNotes/CreditNoteListParams.cs index adff6e83..c53b8908 100644 --- a/src/Orb/Models/CreditNotes/CreditNoteListParams.cs +++ b/src/Orb/Models/CreditNotes/CreditNoteListParams.cs @@ -12,8 +12,12 @@ namespace Orb.Models.CreditNotes; /// Get a paginated list of CreditNotes. Users can also filter by customer_id, subscription_id, /// or external_customer_id. The credit notes will be returned in reverse chronological /// order by `creation_time`. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CreditNoteListParams : ParamsBase +public record class CreditNoteListParams : ParamsBase { public DateTimeOffset? CreatedAtGt { @@ -92,8 +96,11 @@ public long? Limit public CreditNoteListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditNoteListParams(CreditNoteListParams creditNoteListParams) : base(creditNoteListParams) { } +#pragma warning restore CS8618 public CreditNoteListParams( IReadOnlyDictionary rawHeaderData, @@ -128,6 +135,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CreditNoteListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/credit_notes") @@ -144,4 +171,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateParams.cs b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateParams.cs index ac1d4a58..2723f88e 100644 --- a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateParams.cs +++ b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateParams.cs @@ -14,8 +14,12 @@ namespace Orb.Models.Customers.BalanceTransactions; /// /// Creates an immutable balance transaction that updates the customer's balance /// and returns back the newly created transaction. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BalanceTransactionCreateParams : ParamsBase +public record class BalanceTransactionCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -62,6 +66,8 @@ public string? Description public BalanceTransactionCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BalanceTransactionCreateParams( BalanceTransactionCreateParams balanceTransactionCreateParams ) @@ -71,6 +77,7 @@ BalanceTransactionCreateParams balanceTransactionCreateParams this._rawBodyData = new(balanceTransactionCreateParams._rawBodyData); } +#pragma warning restore CS8618 public BalanceTransactionCreateParams( IReadOnlyDictionary rawHeaderData, @@ -111,6 +118,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["CustomerID"] = this.CustomerID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BalanceTransactionCreateParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -139,9 +170,14 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } -[JsonConverter(typeof(global::Orb.Models.Customers.BalanceTransactions.TypeConverter))] +[JsonConverter(typeof(TypeConverter))] public enum Type { Increment, diff --git a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateResponse.cs b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateResponse.cs index 226a4f49..3ebf70c7 100644 --- a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateResponse.cs +++ b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateResponse.cs @@ -30,14 +30,12 @@ public required string ID init { this._rawData.Set("id", value); } } - public required ApiEnum Action + public required ApiEnum Action { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("action"); + return this._rawData.GetNotNullClass>("action"); } init { this._rawData.Set("action", value); } } @@ -192,7 +190,7 @@ IReadOnlyDictionary rawData ) => BalanceTransactionCreateResponse.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Customers.BalanceTransactions.ActionConverter))] +[JsonConverter(typeof(ActionConverter))] public enum Action { AppliedToInvoice, @@ -207,10 +205,9 @@ public enum Action SmallInvoiceCarryover, } -sealed class ActionConverter - : JsonConverter +sealed class ActionConverter : JsonConverter { - public override global::Orb.Models.Customers.BalanceTransactions.Action Read( + public override Action Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -218,100 +215,36 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "applied_to_invoice" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .AppliedToInvoice, - "manual_adjustment" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .ManualAdjustment, - "prorated_refund" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .ProratedRefund, - "revert_prorated_refund" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .RevertProratedRefund, - "return_from_voiding" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .ReturnFromVoiding, - "credit_note_applied" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .CreditNoteApplied, - "credit_note_voided" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .CreditNoteVoided, - "overpayment_refund" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .OverpaymentRefund, - "external_payment" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .ExternalPayment, - "small_invoice_carryover" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .SmallInvoiceCarryover, - _ => (global::Orb.Models.Customers.BalanceTransactions.Action)(-1), + "applied_to_invoice" => Action.AppliedToInvoice, + "manual_adjustment" => Action.ManualAdjustment, + "prorated_refund" => Action.ProratedRefund, + "revert_prorated_refund" => Action.RevertProratedRefund, + "return_from_voiding" => Action.ReturnFromVoiding, + "credit_note_applied" => Action.CreditNoteApplied, + "credit_note_voided" => Action.CreditNoteVoided, + "overpayment_refund" => Action.OverpaymentRefund, + "external_payment" => Action.ExternalPayment, + "small_invoice_carryover" => Action.SmallInvoiceCarryover, + _ => (Action)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Customers.BalanceTransactions.Action value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Action value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Customers.BalanceTransactions.Action.AppliedToInvoice => - "applied_to_invoice", - global::Orb.Models.Customers.BalanceTransactions.Action.ManualAdjustment => - "manual_adjustment", - global::Orb.Models.Customers.BalanceTransactions.Action.ProratedRefund => - "prorated_refund", - global::Orb.Models.Customers.BalanceTransactions.Action.RevertProratedRefund => - "revert_prorated_refund", - global::Orb.Models.Customers.BalanceTransactions.Action.ReturnFromVoiding => - "return_from_voiding", - global::Orb.Models.Customers.BalanceTransactions.Action.CreditNoteApplied => - "credit_note_applied", - global::Orb.Models.Customers.BalanceTransactions.Action.CreditNoteVoided => - "credit_note_voided", - global::Orb.Models.Customers.BalanceTransactions.Action.OverpaymentRefund => - "overpayment_refund", - global::Orb.Models.Customers.BalanceTransactions.Action.ExternalPayment => - "external_payment", - global::Orb.Models.Customers.BalanceTransactions.Action.SmallInvoiceCarryover => - "small_invoice_carryover", + Action.AppliedToInvoice => "applied_to_invoice", + Action.ManualAdjustment => "manual_adjustment", + Action.ProratedRefund => "prorated_refund", + Action.RevertProratedRefund => "revert_prorated_refund", + Action.ReturnFromVoiding => "return_from_voiding", + Action.CreditNoteApplied => "credit_note_applied", + Action.CreditNoteVoided => "credit_note_voided", + Action.OverpaymentRefund => "overpayment_refund", + Action.ExternalPayment => "external_payment", + Action.SmallInvoiceCarryover => "small_invoice_carryover", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListParams.cs b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListParams.cs index fdc3ffad..8538dac6 100644 --- a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListParams.cs +++ b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListParams.cs @@ -28,8 +28,12 @@ namespace Orb.Models.Customers.BalanceTransactions; /// This endpoint retrieves all customer balance transactions in reverse chronological /// order for a single customer, providing a complete audit trail of all adjustments /// and invoice applications. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BalanceTransactionListParams : ParamsBase +public record class BalanceTransactionListParams : ParamsBase { public string? CustomerID { get; init; } @@ -110,11 +114,14 @@ public DateTimeOffset? OperationTimeLte public BalanceTransactionListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BalanceTransactionListParams(BalanceTransactionListParams balanceTransactionListParams) : base(balanceTransactionListParams) { this.CustomerID = balanceTransactionListParams.CustomerID; } +#pragma warning restore CS8618 public BalanceTransactionListParams( IReadOnlyDictionary rawHeaderData, @@ -149,6 +156,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["CustomerID"] = this.CustomerID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BalanceTransactionListParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -168,4 +197,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/Costs/CostListByExternalIDParams.cs b/src/Orb/Models/Customers/Costs/CostListByExternalIDParams.cs index e9fd5b5c..9393c43e 100644 --- a/src/Orb/Models/Customers/Costs/CostListByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Costs/CostListByExternalIDParams.cs @@ -106,8 +106,12 @@ namespace Orb.Models.Customers.Costs; /// costs grouped by those matrix dimensions. Orb will return `price_groups` with /// the `grouping_key` and `secondary_grouping_key` based on the matrix price definition, /// for each `grouping_value` and `secondary_grouping_value` available. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CostListByExternalIDParams : ParamsBase +public record class CostListByExternalIDParams : ParamsBase { public string? ExternalCustomerID { get; init; } @@ -169,11 +173,14 @@ public ApiEnum? ViewMode public CostListByExternalIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CostListByExternalIDParams(CostListByExternalIDParams costListByExternalIDParams) : base(costListByExternalIDParams) { this.ExternalCustomerID = costListByExternalIDParams.ExternalCustomerID; } +#pragma warning restore CS8618 public CostListByExternalIDParams( IReadOnlyDictionary rawHeaderData, @@ -208,6 +215,31 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ExternalCustomerID"] = this.ExternalCustomerID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CostListByExternalIDParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalCustomerID?.Equals(other.ExternalCustomerID) + ?? other.ExternalCustomerID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -230,6 +262,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// diff --git a/src/Orb/Models/Customers/Costs/CostListParams.cs b/src/Orb/Models/Customers/Costs/CostListParams.cs index e87ca914..26d064cb 100644 --- a/src/Orb/Models/Customers/Costs/CostListParams.cs +++ b/src/Orb/Models/Customers/Costs/CostListParams.cs @@ -106,8 +106,12 @@ namespace Orb.Models.Customers.Costs; /// costs grouped by those matrix dimensions. Orb will return `price_groups` with /// the `grouping_key` and `secondary_grouping_key` based on the matrix price definition, /// for each `grouping_value` and `secondary_grouping_value` available. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CostListParams : ParamsBase +public record class CostListParams : ParamsBase { public string? CustomerID { get; init; } @@ -167,11 +171,14 @@ public ApiEnum? ViewMode public CostListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CostListParams(CostListParams costListParams) : base(costListParams) { this.CustomerID = costListParams.CustomerID; } +#pragma warning restore CS8618 public CostListParams( IReadOnlyDictionary rawHeaderData, @@ -206,6 +213,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["CustomerID"] = this.CustomerID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CostListParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -225,6 +254,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// diff --git a/src/Orb/Models/Customers/Credits/CreditListByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/CreditListByExternalIDParams.cs index 07cec886..5ccfb077 100644 --- a/src/Orb/Models/Customers/Credits/CreditListByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/CreditListByExternalIDParams.cs @@ -16,8 +16,12 @@ namespace Orb.Models.Customers.Credits; /// /// Note that `currency` defaults to credits if not specified. To use a real /// world currency, set `currency` to an ISO 4217 string. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CreditListByExternalIDParams : ParamsBase +public record class CreditListByExternalIDParams : ParamsBase { public string? ExternalCustomerID { get; init; } @@ -93,11 +97,14 @@ public long? Limit public CreditListByExternalIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditListByExternalIDParams(CreditListByExternalIDParams creditListByExternalIDParams) : base(creditListByExternalIDParams) { this.ExternalCustomerID = creditListByExternalIDParams.ExternalCustomerID; } +#pragma warning restore CS8618 public CreditListByExternalIDParams( IReadOnlyDictionary rawHeaderData, @@ -132,6 +139,31 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ExternalCustomerID"] = this.ExternalCustomerID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CreditListByExternalIDParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalCustomerID?.Equals(other.ExternalCustomerID) + ?? other.ExternalCustomerID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -154,4 +186,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/Credits/CreditListParams.cs b/src/Orb/Models/Customers/Credits/CreditListParams.cs index 343f39fd..931ab8ec 100644 --- a/src/Orb/Models/Customers/Credits/CreditListParams.cs +++ b/src/Orb/Models/Customers/Credits/CreditListParams.cs @@ -16,8 +16,12 @@ namespace Orb.Models.Customers.Credits; /// /// Note that `currency` defaults to credits if not specified. To use a real /// world currency, set `currency` to an ISO 4217 string. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CreditListParams : ParamsBase +public record class CreditListParams : ParamsBase { public string? CustomerID { get; init; } @@ -93,11 +97,14 @@ public long? Limit public CreditListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditListParams(CreditListParams creditListParams) : base(creditListParams) { this.CustomerID = creditListParams.CustomerID; } +#pragma warning restore CS8618 public CreditListParams( IReadOnlyDictionary rawHeaderData, @@ -132,6 +139,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["CustomerID"] = this.CustomerID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CreditListParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -151,4 +180,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/Credits/CreditListResponse.cs b/src/Orb/Models/Customers/Credits/CreditListResponse.cs index 240ac433..d7ce8b6b 100644 --- a/src/Orb/Models/Customers/Credits/CreditListResponse.cs +++ b/src/Orb/Models/Customers/Credits/CreditListResponse.cs @@ -53,18 +53,16 @@ public required double Balance init { this._rawData.Set("expiry_date", value); } } - public required IReadOnlyList Filters + public required IReadOnlyList Filters { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("filters"); + return this._rawData.GetNotNullStruct>("filters"); } init { - this._rawData.Set>( + this._rawData.Set>( "filters", ImmutableArray.ToImmutableArray(value) ); @@ -91,14 +89,12 @@ public required string? PerUnitCostBasis init { this._rawData.Set("per_unit_cost_basis", value); } } - public required ApiEnum Status + public required ApiEnum Status { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("status"); + return this._rawData.GetNotNullClass>("status"); } init { this._rawData.Set("status", value); } } @@ -156,25 +152,18 @@ public CreditListResponse FromRawUnchecked(IReadOnlyDictionary /// A PriceFilter that only allows item_id field for block filters. /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Customers.Credits.Filter, - global::Orb.Models.Customers.Credits.FilterFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Filter : JsonModel { /// /// The property of the price the block applies to. Only item_id is supported. /// - public required ApiEnum Field + public required ApiEnum Field { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("field"); + return this._rawData.GetNotNullClass>("field"); } init { this._rawData.Set("field", value); } } @@ -182,14 +171,12 @@ public sealed record class Filter : JsonModel /// /// Should prices that match the filter be included or excluded. /// - public required ApiEnum Operator + public required ApiEnum Operator { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("operator"); + return this._rawData.GetNotNullClass>("operator"); } init { this._rawData.Set("operator", value); } } @@ -223,7 +210,7 @@ public override void Validate() public Filter() { } - public Filter(global::Orb.Models.Customers.Credits.Filter filter) + public Filter(Filter filter) : base(filter) { } public Filter(IReadOnlyDictionary rawData) @@ -239,35 +226,32 @@ public Filter(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Customers.Credits.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Filter FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class FilterFromRaw : IFromRawJson +class FilterFromRaw : IFromRawJson { /// - public global::Orb.Models.Customers.Credits.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Customers.Credits.Filter.FromRawUnchecked(rawData); + public Filter FromRawUnchecked(IReadOnlyDictionary rawData) => + Filter.FromRawUnchecked(rawData); } /// /// The property of the price the block applies to. Only item_id is supported. /// -[JsonConverter(typeof(global::Orb.Models.Customers.Credits.FieldConverter))] +[JsonConverter(typeof(FieldConverter))] public enum Field { ItemID, } -sealed class FieldConverter : JsonConverter +sealed class FieldConverter : JsonConverter { - public override global::Orb.Models.Customers.Credits.Field Read( + public override Field Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -275,22 +259,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "item_id" => global::Orb.Models.Customers.Credits.Field.ItemID, - _ => (global::Orb.Models.Customers.Credits.Field)(-1), + "item_id" => Field.ItemID, + _ => (Field)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Customers.Credits.Field value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Field value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Customers.Credits.Field.ItemID => "item_id", + Field.ItemID => "item_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -303,16 +283,16 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(global::Orb.Models.Customers.Credits.OperatorConverter))] +[JsonConverter(typeof(OperatorConverter))] public enum Operator { Includes, Excludes, } -sealed class OperatorConverter : JsonConverter +sealed class OperatorConverter : JsonConverter { - public override global::Orb.Models.Customers.Credits.Operator Read( + public override Operator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -320,24 +300,20 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => global::Orb.Models.Customers.Credits.Operator.Includes, - "excludes" => global::Orb.Models.Customers.Credits.Operator.Excludes, - _ => (global::Orb.Models.Customers.Credits.Operator)(-1), + "includes" => Operator.Includes, + "excludes" => Operator.Excludes, + _ => (Operator)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Customers.Credits.Operator value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Operator value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Customers.Credits.Operator.Includes => "includes", - global::Orb.Models.Customers.Credits.Operator.Excludes => "excludes", + Operator.Includes => "includes", + Operator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -347,16 +323,16 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.Customers.Credits.StatusConverter))] +[JsonConverter(typeof(StatusConverter))] public enum Status { Active, PendingPayment, } -sealed class StatusConverter : JsonConverter +sealed class StatusConverter : JsonConverter { - public override global::Orb.Models.Customers.Credits.Status Read( + public override Status Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -364,24 +340,20 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "active" => global::Orb.Models.Customers.Credits.Status.Active, - "pending_payment" => global::Orb.Models.Customers.Credits.Status.PendingPayment, - _ => (global::Orb.Models.Customers.Credits.Status)(-1), + "active" => Status.Active, + "pending_payment" => Status.PendingPayment, + _ => (Status)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Customers.Credits.Status value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Customers.Credits.Status.Active => "active", - global::Orb.Models.Customers.Credits.Status.PendingPayment => "pending_payment", + Status.Active => "active", + Status.PendingPayment => "pending_payment", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs index 98de1280..77de4183 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs @@ -94,8 +94,12 @@ namespace Orb.Models.Customers.Credits.Ledger; /// of type `amendment`. For this entry, `block_id` is required to identify the block /// that was originally decremented from, and `amount` indicates how many credits /// to return to the customer, up to the block's initial balance. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class LedgerCreateEntryByExternalIDParams : ParamsBase +public record class LedgerCreateEntryByExternalIDParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -119,6 +123,8 @@ public required LedgerCreateEntryByExternalIDParamsBody Body public LedgerCreateEntryByExternalIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerCreateEntryByExternalIDParams( LedgerCreateEntryByExternalIDParams ledgerCreateEntryByExternalIDParams ) @@ -128,6 +134,7 @@ LedgerCreateEntryByExternalIDParams ledgerCreateEntryByExternalIDParams this._rawBodyData = new(ledgerCreateEntryByExternalIDParams._rawBodyData); } +#pragma warning restore CS8618 public LedgerCreateEntryByExternalIDParams( IReadOnlyDictionary rawHeaderData, @@ -168,6 +175,33 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ExternalCustomerID"] = this.ExternalCustomerID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(LedgerCreateEntryByExternalIDParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalCustomerID?.Equals(other.ExternalCustomerID) + ?? other.ExternalCustomerID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -199,6 +233,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(LedgerCreateEntryByExternalIDParamsBodyConverter))] diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs index 47c8a79f..d2a7a00b 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs @@ -94,8 +94,12 @@ namespace Orb.Models.Customers.Credits.Ledger; /// of type `amendment`. For this entry, `block_id` is required to identify the block /// that was originally decremented from, and `amount` indicates how many credits /// to return to the customer, up to the block's initial balance. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class LedgerCreateEntryParams : ParamsBase +public record class LedgerCreateEntryParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -117,6 +121,8 @@ public required Body Body public LedgerCreateEntryParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerCreateEntryParams(LedgerCreateEntryParams ledgerCreateEntryParams) : base(ledgerCreateEntryParams) { @@ -124,6 +130,7 @@ public LedgerCreateEntryParams(LedgerCreateEntryParams ledgerCreateEntryParams) this._rawBodyData = new(ledgerCreateEntryParams._rawBodyData); } +#pragma warning restore CS8618 public LedgerCreateEntryParams( IReadOnlyDictionary rawHeaderData, @@ -164,6 +171,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["CustomerID"] = this.CustomerID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(LedgerCreateEntryParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -192,6 +223,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(BodyConverter))] @@ -800,18 +836,16 @@ public string? Description /// Optional filter to specify which items this credit block applies to. If not /// specified, the block will apply to all items for the pricing unit. /// - public IReadOnlyList? Filters + public IReadOnlyList? Filters { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct< - ImmutableArray - >("filters"); + return this._rawData.GetNullableStruct>("filters"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "filters", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -936,25 +970,18 @@ public Increment FromRawUnchecked(IReadOnlyDictionary rawDa /// /// A PriceFilter that only allows item_id field for block filters. /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Customers.Credits.Ledger.Filter, - global::Orb.Models.Customers.Credits.Ledger.FilterFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Filter : JsonModel { /// /// The property of the price the block applies to. Only item_id is supported. /// - public required ApiEnum Field + public required ApiEnum Field { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("field"); + return this._rawData.GetNotNullClass>("field"); } init { this._rawData.Set("field", value); } } @@ -962,14 +989,12 @@ public sealed record class Filter : JsonModel /// /// Should prices that match the filter be included or excluded. /// - public required ApiEnum Operator + public required ApiEnum Operator { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("operator"); + return this._rawData.GetNotNullClass>("operator"); } init { this._rawData.Set("operator", value); } } @@ -1003,7 +1028,7 @@ public override void Validate() public Filter() { } - public Filter(global::Orb.Models.Customers.Credits.Ledger.Filter filter) + public Filter(Filter filter) : base(filter) { } public Filter(IReadOnlyDictionary rawData) @@ -1019,35 +1044,32 @@ public Filter(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Customers.Credits.Ledger.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Filter FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class FilterFromRaw : IFromRawJson +class FilterFromRaw : IFromRawJson { /// - public global::Orb.Models.Customers.Credits.Ledger.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Customers.Credits.Ledger.Filter.FromRawUnchecked(rawData); + public Filter FromRawUnchecked(IReadOnlyDictionary rawData) => + Filter.FromRawUnchecked(rawData); } /// /// The property of the price the block applies to. Only item_id is supported. /// -[JsonConverter(typeof(global::Orb.Models.Customers.Credits.Ledger.FieldConverter))] +[JsonConverter(typeof(FieldConverter))] public enum Field { ItemID, } -sealed class FieldConverter : JsonConverter +sealed class FieldConverter : JsonConverter { - public override global::Orb.Models.Customers.Credits.Ledger.Field Read( + public override Field Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1055,22 +1077,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "item_id" => global::Orb.Models.Customers.Credits.Ledger.Field.ItemID, - _ => (global::Orb.Models.Customers.Credits.Ledger.Field)(-1), + "item_id" => Field.ItemID, + _ => (Field)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Customers.Credits.Ledger.Field value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Field value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Customers.Credits.Ledger.Field.ItemID => "item_id", + Field.ItemID => "item_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -1083,16 +1101,16 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(global::Orb.Models.Customers.Credits.Ledger.OperatorConverter))] +[JsonConverter(typeof(OperatorConverter))] public enum Operator { Includes, Excludes, } -sealed class OperatorConverter : JsonConverter +sealed class OperatorConverter : JsonConverter { - public override global::Orb.Models.Customers.Credits.Ledger.Operator Read( + public override Operator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1100,24 +1118,20 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => global::Orb.Models.Customers.Credits.Ledger.Operator.Includes, - "excludes" => global::Orb.Models.Customers.Credits.Ledger.Operator.Excludes, - _ => (global::Orb.Models.Customers.Credits.Ledger.Operator)(-1), + "includes" => Operator.Includes, + "excludes" => Operator.Excludes, + _ => (Operator)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Customers.Credits.Ledger.Operator value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Operator value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Customers.Credits.Ledger.Operator.Includes => "includes", - global::Orb.Models.Customers.Credits.Ledger.Operator.Excludes => "excludes", + Operator.Includes => "includes", + Operator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDParams.cs index e2c4466b..b53d970c 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDParams.cs @@ -31,11 +31,8 @@ namespace Orb.Models.Customers.Credits.Ledger; /// /// As usage for a customer is reported into Orb, credits may be deducted according /// to the customer's plan configuration. An automated deduction of this type will -/// result in a ledger entry, also with a starting and ending balance. In order to -/// provide better tracing capabilities for automatic deductions, Orb always associates -/// each automatic deduction with the `event_id` at the time of ingestion, used to -/// pinpoint _why_ credit deduction took place and to ensure that credits are never -/// deducted without an associated usage event. +/// result in a ledger entry, also with a starting and ending balance. Each day's +/// usage for a particular price, invoice, and block will be grouped into a single entry. /// /// By default, Orb uses an algorithm that automatically deducts from the *soonest /// expiring credit block* first in order to ensure that all credits are utilized @@ -77,8 +74,12 @@ namespace Orb.Models.Customers.Credits.Ledger; /// ## Amendment When credits are added to a customer's balance as a result /// of a correction, this entry will be added to the ledger to indicate the adjustment /// of credits. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class LedgerListByExternalIDParams : ParamsBase +public record class LedgerListByExternalIDParams : ParamsBase { public string? ExternalCustomerID { get; init; } @@ -206,11 +207,14 @@ public string? MinimumAmount public LedgerListByExternalIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerListByExternalIDParams(LedgerListByExternalIDParams ledgerListByExternalIDParams) : base(ledgerListByExternalIDParams) { this.ExternalCustomerID = ledgerListByExternalIDParams.ExternalCustomerID; } +#pragma warning restore CS8618 public LedgerListByExternalIDParams( IReadOnlyDictionary rawHeaderData, @@ -245,6 +249,31 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ExternalCustomerID"] = this.ExternalCustomerID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(LedgerListByExternalIDParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalCustomerID?.Equals(other.ExternalCustomerID) + ?? other.ExternalCustomerID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -267,6 +296,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(LedgerListByExternalIDParamsEntryStatusConverter))] diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerListParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListParams.cs index 6e6519a4..25e99de7 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListParams.cs @@ -31,11 +31,8 @@ namespace Orb.Models.Customers.Credits.Ledger; /// /// As usage for a customer is reported into Orb, credits may be deducted according /// to the customer's plan configuration. An automated deduction of this type will -/// result in a ledger entry, also with a starting and ending balance. In order to -/// provide better tracing capabilities for automatic deductions, Orb always associates -/// each automatic deduction with the `event_id` at the time of ingestion, used to -/// pinpoint _why_ credit deduction took place and to ensure that credits are never -/// deducted without an associated usage event. +/// result in a ledger entry, also with a starting and ending balance. Each day's +/// usage for a particular price, invoice, and block will be grouped into a single entry. /// /// By default, Orb uses an algorithm that automatically deducts from the *soonest /// expiring credit block* first in order to ensure that all credits are utilized @@ -77,8 +74,12 @@ namespace Orb.Models.Customers.Credits.Ledger; /// ## Amendment When credits are added to a customer's balance as a result /// of a correction, this entry will be added to the ledger to indicate the adjustment /// of credits. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class LedgerListParams : ParamsBase +public record class LedgerListParams : ParamsBase { public string? CustomerID { get; init; } @@ -204,11 +205,14 @@ public string? MinimumAmount public LedgerListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerListParams(LedgerListParams ledgerListParams) : base(ledgerListParams) { this.CustomerID = ledgerListParams.CustomerID; } +#pragma warning restore CS8618 public LedgerListParams( IReadOnlyDictionary rawHeaderData, @@ -243,6 +247,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["CustomerID"] = this.CustomerID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(LedgerListParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -262,6 +288,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(EntryStatusConverter))] diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParams.cs index c260d51f..0b32a35b 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParams.cs @@ -18,8 +18,12 @@ namespace Orb.Models.Customers.Credits.TopUps; /// /// If a top-up already exists for this customer in the same currency, the existing /// top-up will be replaced. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TopUpCreateByExternalIDParams : ParamsBase +public record class TopUpCreateByExternalIDParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -143,6 +147,8 @@ public ApiEnum? ExpiresAf public TopUpCreateByExternalIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpCreateByExternalIDParams( TopUpCreateByExternalIDParams topUpCreateByExternalIDParams ) @@ -152,6 +158,7 @@ TopUpCreateByExternalIDParams topUpCreateByExternalIDParams this._rawBodyData = new(topUpCreateByExternalIDParams._rawBodyData); } +#pragma warning restore CS8618 public TopUpCreateByExternalIDParams( IReadOnlyDictionary rawHeaderData, @@ -192,6 +199,33 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ExternalCustomerID"] = this.ExternalCustomerID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TopUpCreateByExternalIDParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalCustomerID?.Equals(other.ExternalCustomerID) + ?? other.ExternalCustomerID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -223,6 +257,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateParams.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateParams.cs index 3d1ff3c2..8d310fcb 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateParams.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateParams.cs @@ -18,8 +18,12 @@ namespace Orb.Models.Customers.Credits.TopUps; /// /// If a top-up already exists for this customer in the same currency, the existing /// top-up will be replaced. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TopUpCreateParams : ParamsBase +public record class TopUpCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -141,6 +145,8 @@ public ApiEnum? ExpiresAfterUnit public TopUpCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpCreateParams(TopUpCreateParams topUpCreateParams) : base(topUpCreateParams) { @@ -148,6 +154,7 @@ public TopUpCreateParams(TopUpCreateParams topUpCreateParams) this._rawBodyData = new(topUpCreateParams._rawBodyData); } +#pragma warning restore CS8618 public TopUpCreateParams( IReadOnlyDictionary rawHeaderData, @@ -188,6 +195,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["CustomerID"] = this.CustomerID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TopUpCreateParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -216,6 +247,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteByExternalIDParams.cs index 67c920de..108aa80b 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteByExternalIDParams.cs @@ -11,8 +11,12 @@ namespace Orb.Models.Customers.Credits.TopUps; /// /// This deactivates the top-up and voids any invoices associated with pending credit /// blocks purchased through the top-up. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TopUpDeleteByExternalIDParams : ParamsBase +public record class TopUpDeleteByExternalIDParams : ParamsBase { public required string ExternalCustomerID { get; init; } @@ -20,6 +24,8 @@ public sealed record class TopUpDeleteByExternalIDParams : ParamsBase public TopUpDeleteByExternalIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpDeleteByExternalIDParams( TopUpDeleteByExternalIDParams topUpDeleteByExternalIDParams ) @@ -28,6 +34,7 @@ TopUpDeleteByExternalIDParams topUpDeleteByExternalIDParams this.ExternalCustomerID = topUpDeleteByExternalIDParams.ExternalCustomerID; this.TopUpID = topUpDeleteByExternalIDParams.TopUpID; } +#pragma warning restore CS8618 public TopUpDeleteByExternalIDParams( IReadOnlyDictionary rawHeaderData, @@ -62,6 +69,30 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ExternalCustomerID"] = this.ExternalCustomerID, + ["TopUpID"] = this.TopUpID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TopUpDeleteByExternalIDParams? other) + { + if (other == null) + { + return false; + } + return this.ExternalCustomerID.Equals(other.ExternalCustomerID) + && (this.TopUpID?.Equals(other.TopUpID) ?? other.TopUpID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -85,4 +116,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteParams.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteParams.cs index 581c2ebd..6185f293 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteParams.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteParams.cs @@ -11,8 +11,12 @@ namespace Orb.Models.Customers.Credits.TopUps; /// /// This deactivates the top-up and voids any invoices associated with pending credit /// blocks purchased through the top-up. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TopUpDeleteParams : ParamsBase +public record class TopUpDeleteParams : ParamsBase { public required string CustomerID { get; init; } @@ -20,12 +24,15 @@ public sealed record class TopUpDeleteParams : ParamsBase public TopUpDeleteParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpDeleteParams(TopUpDeleteParams topUpDeleteParams) : base(topUpDeleteParams) { this.CustomerID = topUpDeleteParams.CustomerID; this.TopUpID = topUpDeleteParams.TopUpID; } +#pragma warning restore CS8618 public TopUpDeleteParams( IReadOnlyDictionary rawHeaderData, @@ -60,6 +67,30 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["CustomerID"] = this.CustomerID, + ["TopUpID"] = this.TopUpID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TopUpDeleteParams? other) + { + if (other == null) + { + return false; + } + return this.CustomerID.Equals(other.CustomerID) + && (this.TopUpID?.Equals(other.TopUpID) ?? other.TopUpID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -79,4 +110,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDParams.cs index 4ea1cbcf..63e1fec2 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDParams.cs @@ -10,8 +10,12 @@ namespace Orb.Models.Customers.Credits.TopUps; /// /// List top-ups by external ID +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TopUpListByExternalIDParams : ParamsBase +public record class TopUpListByExternalIDParams : ParamsBase { public string? ExternalCustomerID { get; init; } @@ -52,11 +56,14 @@ public long? Limit public TopUpListByExternalIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpListByExternalIDParams(TopUpListByExternalIDParams topUpListByExternalIDParams) : base(topUpListByExternalIDParams) { this.ExternalCustomerID = topUpListByExternalIDParams.ExternalCustomerID; } +#pragma warning restore CS8618 public TopUpListByExternalIDParams( IReadOnlyDictionary rawHeaderData, @@ -91,6 +98,31 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ExternalCustomerID"] = this.ExternalCustomerID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TopUpListByExternalIDParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalCustomerID?.Equals(other.ExternalCustomerID) + ?? other.ExternalCustomerID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -113,4 +145,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpListParams.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpListParams.cs index affa167c..2976230c 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpListParams.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpListParams.cs @@ -10,8 +10,12 @@ namespace Orb.Models.Customers.Credits.TopUps; /// /// List top-ups +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TopUpListParams : ParamsBase +public record class TopUpListParams : ParamsBase { public string? CustomerID { get; init; } @@ -52,11 +56,14 @@ public long? Limit public TopUpListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpListParams(TopUpListParams topUpListParams) : base(topUpListParams) { this.CustomerID = topUpListParams.CustomerID; } +#pragma warning restore CS8618 public TopUpListParams( IReadOnlyDictionary rawHeaderData, @@ -91,6 +98,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["CustomerID"] = this.CustomerID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TopUpListParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -110,4 +139,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/CustomerCreateParams.cs b/src/Orb/Models/Customers/CustomerCreateParams.cs index f548db5b..65d75f56 100644 --- a/src/Orb/Models/Customers/CustomerCreateParams.cs +++ b/src/Orb/Models/Customers/CustomerCreateParams.cs @@ -22,8 +22,12 @@ namespace Orb.Models.Customers; /// to automatically issue invoices * [Customer ID Aliases](/events-and-metrics/customer-aliases) /// can be configured by setting `external_customer_id` * [Timezone localization](/essentials/timezones) /// can be configured on a per-customer basis by setting the `timezone` parameter +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CustomerCreateParams : ParamsBase +public record class CustomerCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -417,11 +421,14 @@ public string? Timezone public CustomerCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerCreateParams(CustomerCreateParams customerCreateParams) : base(customerCreateParams) { this._rawBodyData = new(customerCreateParams._rawBodyData); } +#pragma warning restore CS8618 public CustomerCreateParams( IReadOnlyDictionary rawHeaderData, @@ -462,6 +469,28 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CustomerCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/customers") @@ -487,6 +516,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -499,14 +533,14 @@ public sealed record class PaymentConfiguration : JsonModel /// /// Provider-specific payment configuration. /// - public IReadOnlyList? PaymentProviders + public IReadOnlyList? PaymentProviders { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct< - ImmutableArray - >("payment_providers"); + return this._rawData.GetNullableStruct>( + "payment_providers" + ); } init { @@ -515,7 +549,7 @@ public sealed record class PaymentConfiguration : JsonModel return; } - this._rawData.Set?>( + this._rawData.Set?>( "payment_providers", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -566,9 +600,7 @@ IReadOnlyDictionary rawData ) => PaymentConfiguration.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(JsonModelConverter) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class PaymentProvider : JsonModel { /// @@ -623,7 +655,7 @@ public override void Validate() public PaymentProvider() { } - public PaymentProvider(global::Orb.Models.Customers.PaymentProvider paymentProvider) + public PaymentProvider(PaymentProvider paymentProvider) : base(paymentProvider) { } public PaymentProvider(IReadOnlyDictionary rawData) @@ -640,9 +672,7 @@ public PaymentProvider(IReadOnlyDictionary rawData) #pragma warning restore CS8618 /// - public static global::Orb.Models.Customers.PaymentProvider FromRawUnchecked( - IReadOnlyDictionary rawData - ) + public static PaymentProvider FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } @@ -655,12 +685,11 @@ public PaymentProvider(ApiEnum providerType) } } -class PaymentProviderFromRaw : IFromRawJson +class PaymentProviderFromRaw : IFromRawJson { /// - public global::Orb.Models.Customers.PaymentProvider FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Customers.PaymentProvider.FromRawUnchecked(rawData); + public PaymentProvider FromRawUnchecked(IReadOnlyDictionary rawData) => + PaymentProvider.FromRawUnchecked(rawData); } /// diff --git a/src/Orb/Models/Customers/CustomerDeleteParams.cs b/src/Orb/Models/Customers/CustomerDeleteParams.cs index 9ea9ff62..005b9a5b 100644 --- a/src/Orb/Models/Customers/CustomerDeleteParams.cs +++ b/src/Orb/Models/Customers/CustomerDeleteParams.cs @@ -20,18 +20,25 @@ namespace Orb.Models.Customers; /// take a few minutes to propagate to related resources. However, querying for the /// customer on subsequent GET requests while deletion is in process will reflect /// its deletion. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CustomerDeleteParams : ParamsBase +public record class CustomerDeleteParams : ParamsBase { public string? CustomerID { get; init; } public CustomerDeleteParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerDeleteParams(CustomerDeleteParams customerDeleteParams) : base(customerDeleteParams) { this.CustomerID = customerDeleteParams.CustomerID; } +#pragma warning restore CS8618 public CustomerDeleteParams( IReadOnlyDictionary rawHeaderData, @@ -66,6 +73,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["CustomerID"] = this.CustomerID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CustomerDeleteParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -85,4 +114,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/CustomerFetchByExternalIDParams.cs b/src/Orb/Models/Customers/CustomerFetchByExternalIDParams.cs index 567a2064..75aae920 100644 --- a/src/Orb/Models/Customers/CustomerFetchByExternalIDParams.cs +++ b/src/Orb/Models/Customers/CustomerFetchByExternalIDParams.cs @@ -13,13 +13,19 @@ namespace Orb.Models.Customers; /// (see [Customer ID Aliases](/events-and-metrics/customer-aliases)). /// /// Note that the resource and semantics of this endpoint exactly mirror [Get Customer](fetch-customer). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CustomerFetchByExternalIDParams : ParamsBase +public record class CustomerFetchByExternalIDParams : ParamsBase { public string? ExternalCustomerID { get; init; } public CustomerFetchByExternalIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerFetchByExternalIDParams( CustomerFetchByExternalIDParams customerFetchByExternalIDParams ) @@ -27,6 +33,7 @@ CustomerFetchByExternalIDParams customerFetchByExternalIDParams { this.ExternalCustomerID = customerFetchByExternalIDParams.ExternalCustomerID; } +#pragma warning restore CS8618 public CustomerFetchByExternalIDParams( IReadOnlyDictionary rawHeaderData, @@ -61,6 +68,31 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ExternalCustomerID"] = this.ExternalCustomerID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CustomerFetchByExternalIDParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalCustomerID?.Equals(other.ExternalCustomerID) + ?? other.ExternalCustomerID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -80,4 +112,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/CustomerFetchParams.cs b/src/Orb/Models/Customers/CustomerFetchParams.cs index df3020ce..341e9233 100644 --- a/src/Orb/Models/Customers/CustomerFetchParams.cs +++ b/src/Orb/Models/Customers/CustomerFetchParams.cs @@ -15,18 +15,25 @@ namespace Orb.Models.Customers; /// /// See the [Customer resource](/core-concepts#customer) for a full discussion /// of the Customer model. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CustomerFetchParams : ParamsBase +public record class CustomerFetchParams : ParamsBase { public string? CustomerID { get; init; } public CustomerFetchParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerFetchParams(CustomerFetchParams customerFetchParams) : base(customerFetchParams) { this.CustomerID = customerFetchParams.CustomerID; } +#pragma warning restore CS8618 public CustomerFetchParams( IReadOnlyDictionary rawHeaderData, @@ -61,6 +68,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["CustomerID"] = this.CustomerID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CustomerFetchParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -80,4 +109,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/CustomerListParams.cs b/src/Orb/Models/Customers/CustomerListParams.cs index aa88c2b6..2e7ed917 100644 --- a/src/Orb/Models/Customers/CustomerListParams.cs +++ b/src/Orb/Models/Customers/CustomerListParams.cs @@ -14,8 +14,12 @@ namespace Orb.Models.Customers; /// Orb's [standardized pagination format](/api-reference/pagination). /// /// See [Customer](/core-concepts##customer) for an overview of the customer model. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CustomerListParams : ParamsBase +public record class CustomerListParams : ParamsBase { public DateTimeOffset? CreatedAtGt { @@ -94,8 +98,11 @@ public long? Limit public CustomerListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerListParams(CustomerListParams customerListParams) : base(customerListParams) { } +#pragma warning restore CS8618 public CustomerListParams( IReadOnlyDictionary rawHeaderData, @@ -130,6 +137,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CustomerListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/customers") @@ -146,4 +173,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams.cs b/src/Orb/Models/Customers/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams.cs index 33327606..29778cac 100644 --- a/src/Orb/Models/Customers/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams.cs +++ b/src/Orb/Models/Customers/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams.cs @@ -15,14 +15,19 @@ namespace Orb.Models.Customers; /// to be charged, ensuring that the most up-to-date payment method is charged. /// /// **Note**: This functionality is currently only available for Stripe. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams - : ParamsBase +public record class CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams : ParamsBase { public string? ExternalCustomerID { get; init; } public CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams( CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams customerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams ) @@ -31,6 +36,7 @@ CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams customerSyncPaym this.ExternalCustomerID = customerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams.ExternalCustomerID; } +#pragma warning restore CS8618 public CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams( IReadOnlyDictionary rawHeaderData, @@ -65,6 +71,33 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ExternalCustomerID"] = this.ExternalCustomerID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals( + CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams? other + ) + { + if (other == null) + { + return false; + } + return ( + this.ExternalCustomerID?.Equals(other.ExternalCustomerID) + ?? other.ExternalCustomerID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -87,4 +120,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/CustomerSyncPaymentMethodsFromGatewayParams.cs b/src/Orb/Models/Customers/CustomerSyncPaymentMethodsFromGatewayParams.cs index b48588ff..d1630f40 100644 --- a/src/Orb/Models/Customers/CustomerSyncPaymentMethodsFromGatewayParams.cs +++ b/src/Orb/Models/Customers/CustomerSyncPaymentMethodsFromGatewayParams.cs @@ -15,13 +15,19 @@ namespace Orb.Models.Customers; /// to be charged, ensuring that the most up-to-date payment method is charged. /// /// **Note**: This functionality is currently only available for Stripe. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CustomerSyncPaymentMethodsFromGatewayParams : ParamsBase +public record class CustomerSyncPaymentMethodsFromGatewayParams : ParamsBase { public string? CustomerID { get; init; } public CustomerSyncPaymentMethodsFromGatewayParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerSyncPaymentMethodsFromGatewayParams( CustomerSyncPaymentMethodsFromGatewayParams customerSyncPaymentMethodsFromGatewayParams ) @@ -29,6 +35,7 @@ CustomerSyncPaymentMethodsFromGatewayParams customerSyncPaymentMethodsFromGatewa { this.CustomerID = customerSyncPaymentMethodsFromGatewayParams.CustomerID; } +#pragma warning restore CS8618 public CustomerSyncPaymentMethodsFromGatewayParams( IReadOnlyDictionary rawHeaderData, @@ -63,6 +70,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["CustomerID"] = this.CustomerID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CustomerSyncPaymentMethodsFromGatewayParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -82,4 +111,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs b/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs index cdaab38b..e27bc465 100644 --- a/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs +++ b/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs @@ -16,8 +16,12 @@ namespace Orb.Models.Customers; /// This endpoint is used to update customer details given an `external_customer_id` /// (see [Customer ID Aliases](/events-and-metrics/customer-aliases)). Note that the /// resource and semantics of this endpoint exactly mirror [Update Customer](update-customer). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CustomerUpdateByExternalIDParams : ParamsBase +public record class CustomerUpdateByExternalIDParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -403,6 +407,8 @@ public CustomerTaxID? TaxID public CustomerUpdateByExternalIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateByExternalIDParams( CustomerUpdateByExternalIDParams customerUpdateByExternalIDParams ) @@ -412,6 +418,7 @@ CustomerUpdateByExternalIDParams customerUpdateByExternalIDParams this._rawBodyData = new(customerUpdateByExternalIDParams._rawBodyData); } +#pragma warning restore CS8618 public CustomerUpdateByExternalIDParams( IReadOnlyDictionary rawHeaderData, @@ -452,6 +459,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ID"] = this.ID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CustomerUpdateByExternalIDParams? other) + { + if (other == null) + { + return false; + } + return (this.ID?.Equals(other.ID) ?? other.ID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -480,6 +511,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// diff --git a/src/Orb/Models/Customers/CustomerUpdateParams.cs b/src/Orb/Models/Customers/CustomerUpdateParams.cs index 084533d4..7533d7c2 100644 --- a/src/Orb/Models/Customers/CustomerUpdateParams.cs +++ b/src/Orb/Models/Customers/CustomerUpdateParams.cs @@ -17,8 +17,12 @@ namespace Orb.Models.Customers; /// `name`, `email`, `email_delivery`, `tax_id`, `auto_collection`, `metadata`, `shipping_address`, /// `billing_address`, and `additional_emails` of an existing customer. Other fields /// on a customer are currently immutable. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CustomerUpdateParams : ParamsBase +public record class CustomerUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -404,6 +408,8 @@ public CustomerTaxID? TaxID public CustomerUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateParams(CustomerUpdateParams customerUpdateParams) : base(customerUpdateParams) { @@ -411,6 +417,7 @@ public CustomerUpdateParams(CustomerUpdateParams customerUpdateParams) this._rawBodyData = new(customerUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public CustomerUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -451,6 +458,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["CustomerID"] = this.CustomerID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CustomerUpdateParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -479,6 +510,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// diff --git a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupCreateParams.cs b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupCreateParams.cs index 727a7b7a..2796c58a 100644 --- a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupCreateParams.cs +++ b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupCreateParams.cs @@ -19,8 +19,12 @@ namespace Orb.Models.DimensionalPriceGroups; /// of widgets used and we want to charge differently depending on the color of the /// widget. We can create a price group with a dimension "color" and two prices: one /// that charges \$10 per red widget and one that charges \$20 per blue widget. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class DimensionalPriceGroupCreateParams : ParamsBase +public record class DimensionalPriceGroupCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -104,6 +108,8 @@ public string? ExternalDimensionalPriceGroupID public DimensionalPriceGroupCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public DimensionalPriceGroupCreateParams( DimensionalPriceGroupCreateParams dimensionalPriceGroupCreateParams ) @@ -111,6 +117,7 @@ DimensionalPriceGroupCreateParams dimensionalPriceGroupCreateParams { this._rawBodyData = new(dimensionalPriceGroupCreateParams._rawBodyData); } +#pragma warning restore CS8618 public DimensionalPriceGroupCreateParams( IReadOnlyDictionary rawHeaderData, @@ -151,6 +158,28 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(DimensionalPriceGroupCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/dimensional_price_groups") @@ -176,4 +205,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListParams.cs b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListParams.cs index b0850dda..6b10d044 100644 --- a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListParams.cs +++ b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListParams.cs @@ -10,8 +10,12 @@ namespace Orb.Models.DimensionalPriceGroups; /// /// List dimensional price groups +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class DimensionalPriceGroupListParams : ParamsBase +public record class DimensionalPriceGroupListParams : ParamsBase { /// /// Cursor for pagination. This can be populated by the `next_cursor` value returned @@ -50,10 +54,13 @@ public long? Limit public DimensionalPriceGroupListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public DimensionalPriceGroupListParams( DimensionalPriceGroupListParams dimensionalPriceGroupListParams ) : base(dimensionalPriceGroupListParams) { } +#pragma warning restore CS8618 public DimensionalPriceGroupListParams( IReadOnlyDictionary rawHeaderData, @@ -88,6 +95,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(DimensionalPriceGroupListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/dimensional_price_groups") @@ -104,4 +131,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupRetrieveParams.cs b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupRetrieveParams.cs index 703425c8..c4227c5f 100644 --- a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupRetrieveParams.cs +++ b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupRetrieveParams.cs @@ -10,13 +10,19 @@ namespace Orb.Models.DimensionalPriceGroups; /// /// Fetch dimensional price group +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class DimensionalPriceGroupRetrieveParams : ParamsBase +public record class DimensionalPriceGroupRetrieveParams : ParamsBase { public string? DimensionalPriceGroupID { get; init; } public DimensionalPriceGroupRetrieveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public DimensionalPriceGroupRetrieveParams( DimensionalPriceGroupRetrieveParams dimensionalPriceGroupRetrieveParams ) @@ -24,6 +30,7 @@ DimensionalPriceGroupRetrieveParams dimensionalPriceGroupRetrieveParams { this.DimensionalPriceGroupID = dimensionalPriceGroupRetrieveParams.DimensionalPriceGroupID; } +#pragma warning restore CS8618 public DimensionalPriceGroupRetrieveParams( IReadOnlyDictionary rawHeaderData, @@ -58,6 +65,31 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["DimensionalPriceGroupID"] = this.DimensionalPriceGroupID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(DimensionalPriceGroupRetrieveParams? other) + { + if (other == null) + { + return false; + } + return ( + this.DimensionalPriceGroupID?.Equals(other.DimensionalPriceGroupID) + ?? other.DimensionalPriceGroupID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -77,4 +109,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupUpdateParams.cs b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupUpdateParams.cs index 14f6f05e..4da736ea 100644 --- a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupUpdateParams.cs +++ b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupUpdateParams.cs @@ -13,8 +13,12 @@ namespace Orb.Models.DimensionalPriceGroups; /// This endpoint can be used to update the `external_dimensional_price_group_id` /// and `metadata` of an existing dimensional price group. Other fields on a dimensional /// price group are currently immutable. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class DimensionalPriceGroupUpdateParams : ParamsBase +public record class DimensionalPriceGroupUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -67,6 +71,8 @@ public string? ExternalDimensionalPriceGroupID public DimensionalPriceGroupUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public DimensionalPriceGroupUpdateParams( DimensionalPriceGroupUpdateParams dimensionalPriceGroupUpdateParams ) @@ -76,6 +82,7 @@ DimensionalPriceGroupUpdateParams dimensionalPriceGroupUpdateParams this._rawBodyData = new(dimensionalPriceGroupUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public DimensionalPriceGroupUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -116,6 +123,33 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["DimensionalPriceGroupID"] = this.DimensionalPriceGroupID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(DimensionalPriceGroupUpdateParams? other) + { + if (other == null) + { + return false; + } + return ( + this.DimensionalPriceGroupID?.Equals(other.DimensionalPriceGroupID) + ?? other.DimensionalPriceGroupID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -144,4 +178,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDRetrieveParams.cs b/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDRetrieveParams.cs index abd46f11..f3758a19 100644 --- a/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDRetrieveParams.cs +++ b/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDRetrieveParams.cs @@ -10,13 +10,19 @@ namespace Orb.Models.DimensionalPriceGroups.ExternalDimensionalPriceGroupID; /// /// Fetch dimensional price group by external ID +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ExternalDimensionalPriceGroupIDRetrieveParams : ParamsBase +public record class ExternalDimensionalPriceGroupIDRetrieveParams : ParamsBase { public string? ExternalDimensionalPriceGroupID { get; init; } public ExternalDimensionalPriceGroupIDRetrieveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ExternalDimensionalPriceGroupIDRetrieveParams( ExternalDimensionalPriceGroupIDRetrieveParams externalDimensionalPriceGroupIDRetrieveParams ) @@ -25,6 +31,7 @@ ExternalDimensionalPriceGroupIDRetrieveParams externalDimensionalPriceGroupIDRet this.ExternalDimensionalPriceGroupID = externalDimensionalPriceGroupIDRetrieveParams.ExternalDimensionalPriceGroupID; } +#pragma warning restore CS8618 public ExternalDimensionalPriceGroupIDRetrieveParams( IReadOnlyDictionary rawHeaderData, @@ -59,6 +66,31 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ExternalDimensionalPriceGroupID"] = this.ExternalDimensionalPriceGroupID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ExternalDimensionalPriceGroupIDRetrieveParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalDimensionalPriceGroupID?.Equals(other.ExternalDimensionalPriceGroupID) + ?? other.ExternalDimensionalPriceGroupID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -81,4 +113,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDUpdateParams.cs b/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDUpdateParams.cs index ff325e1f..658a87ee 100644 --- a/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDUpdateParams.cs +++ b/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDUpdateParams.cs @@ -13,8 +13,12 @@ namespace Orb.Models.DimensionalPriceGroups.ExternalDimensionalPriceGroupID; /// This endpoint can be used to update the `external_dimensional_price_group_id` /// and `metadata` of an existing dimensional price group. Other fields on a dimensional /// price group are currently immutable. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ExternalDimensionalPriceGroupIDUpdateParams : ParamsBase +public record class ExternalDimensionalPriceGroupIDUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -67,6 +71,8 @@ public string? ExternalDimensionalPriceGroupIDValue public ExternalDimensionalPriceGroupIDUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ExternalDimensionalPriceGroupIDUpdateParams( ExternalDimensionalPriceGroupIDUpdateParams externalDimensionalPriceGroupIDUpdateParams ) @@ -77,6 +83,7 @@ ExternalDimensionalPriceGroupIDUpdateParams externalDimensionalPriceGroupIDUpdat this._rawBodyData = new(externalDimensionalPriceGroupIDUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public ExternalDimensionalPriceGroupIDUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -117,6 +124,33 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ExternalDimensionalPriceGroupID"] = this.ExternalDimensionalPriceGroupID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ExternalDimensionalPriceGroupIDUpdateParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalDimensionalPriceGroupID?.Equals(other.ExternalDimensionalPriceGroupID) + ?? other.ExternalDimensionalPriceGroupID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -148,4 +182,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Events/Backfills/BackfillCloseParams.cs b/src/Orb/Models/Events/Backfills/BackfillCloseParams.cs index e35f39d3..0273ed5f 100644 --- a/src/Orb/Models/Events/Backfills/BackfillCloseParams.cs +++ b/src/Orb/Models/Events/Backfills/BackfillCloseParams.cs @@ -13,18 +13,25 @@ namespace Orb.Models.Events.Backfills; /// Orb will asynchronously reflect the updated usage in invoice amounts and usage /// graphs. Once all of the updates are complete, the backfill's status will transition /// to `reflected`. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BackfillCloseParams : ParamsBase +public record class BackfillCloseParams : ParamsBase { public string? BackfillID { get; init; } public BackfillCloseParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BackfillCloseParams(BackfillCloseParams backfillCloseParams) : base(backfillCloseParams) { this.BackfillID = backfillCloseParams.BackfillID; } +#pragma warning restore CS8618 public BackfillCloseParams( IReadOnlyDictionary rawHeaderData, @@ -59,6 +66,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["BackfillID"] = this.BackfillID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BackfillCloseParams? other) + { + if (other == null) + { + return false; + } + return (this.BackfillID?.Equals(other.BackfillID) ?? other.BackfillID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -78,4 +107,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Events/Backfills/BackfillCreateParams.cs b/src/Orb/Models/Events/Backfills/BackfillCreateParams.cs index 599437f1..da21ba31 100644 --- a/src/Orb/Models/Events/Backfills/BackfillCreateParams.cs +++ b/src/Orb/Models/Events/Backfills/BackfillCreateParams.cs @@ -45,8 +45,12 @@ namespace Orb.Models.Events.Backfills; /// /// You may not have multiple backfills in a pending or pending_revert state /// with overlapping timeframes. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BackfillCreateParams : ParamsBase +public record class BackfillCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -165,11 +169,14 @@ public bool? ReplaceExistingEvents public BackfillCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BackfillCreateParams(BackfillCreateParams backfillCreateParams) : base(backfillCreateParams) { this._rawBodyData = new(backfillCreateParams._rawBodyData); } +#pragma warning restore CS8618 public BackfillCreateParams( IReadOnlyDictionary rawHeaderData, @@ -210,6 +217,28 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BackfillCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/events/backfills") @@ -235,4 +264,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Events/Backfills/BackfillCreateResponse.cs b/src/Orb/Models/Events/Backfills/BackfillCreateResponse.cs index 8e39a8db..686a4118 100644 --- a/src/Orb/Models/Events/Backfills/BackfillCreateResponse.cs +++ b/src/Orb/Models/Events/Backfills/BackfillCreateResponse.cs @@ -108,14 +108,12 @@ public required bool ReplaceExistingEvents /// /// The status of the backfill. /// - public required ApiEnum Status + public required ApiEnum Status { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("status"); + return this._rawData.GetNotNullClass>("status"); } init { this._rawData.Set("status", value); } } @@ -208,7 +206,7 @@ IReadOnlyDictionary rawData /// /// The status of the backfill. /// -[JsonConverter(typeof(global::Orb.Models.Events.Backfills.StatusConverter))] +[JsonConverter(typeof(StatusConverter))] public enum Status { Pending, @@ -217,9 +215,9 @@ public enum Status Reverted, } -sealed class StatusConverter : JsonConverter +sealed class StatusConverter : JsonConverter { - public override global::Orb.Models.Events.Backfills.Status Read( + public override Status Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -227,28 +225,24 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "pending" => global::Orb.Models.Events.Backfills.Status.Pending, - "reflected" => global::Orb.Models.Events.Backfills.Status.Reflected, - "pending_revert" => global::Orb.Models.Events.Backfills.Status.PendingRevert, - "reverted" => global::Orb.Models.Events.Backfills.Status.Reverted, - _ => (global::Orb.Models.Events.Backfills.Status)(-1), + "pending" => Status.Pending, + "reflected" => Status.Reflected, + "pending_revert" => Status.PendingRevert, + "reverted" => Status.Reverted, + _ => (Status)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Events.Backfills.Status value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Events.Backfills.Status.Pending => "pending", - global::Orb.Models.Events.Backfills.Status.Reflected => "reflected", - global::Orb.Models.Events.Backfills.Status.PendingRevert => "pending_revert", - global::Orb.Models.Events.Backfills.Status.Reverted => "reverted", + Status.Pending => "pending", + Status.Reflected => "reflected", + Status.PendingRevert => "pending_revert", + Status.Reverted => "reverted", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Events/Backfills/BackfillFetchParams.cs b/src/Orb/Models/Events/Backfills/BackfillFetchParams.cs index da16f794..d843457e 100644 --- a/src/Orb/Models/Events/Backfills/BackfillFetchParams.cs +++ b/src/Orb/Models/Events/Backfills/BackfillFetchParams.cs @@ -10,18 +10,25 @@ namespace Orb.Models.Events.Backfills; /// /// This endpoint is used to fetch a backfill given an identifier. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BackfillFetchParams : ParamsBase +public record class BackfillFetchParams : ParamsBase { public string? BackfillID { get; init; } public BackfillFetchParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BackfillFetchParams(BackfillFetchParams backfillFetchParams) : base(backfillFetchParams) { this.BackfillID = backfillFetchParams.BackfillID; } +#pragma warning restore CS8618 public BackfillFetchParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["BackfillID"] = this.BackfillID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BackfillFetchParams? other) + { + if (other == null) + { + return false; + } + return (this.BackfillID?.Equals(other.BackfillID) ?? other.BackfillID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -75,4 +104,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Events/Backfills/BackfillListParams.cs b/src/Orb/Models/Events/Backfills/BackfillListParams.cs index bde773bd..08526fa5 100644 --- a/src/Orb/Models/Events/Backfills/BackfillListParams.cs +++ b/src/Orb/Models/Events/Backfills/BackfillListParams.cs @@ -15,8 +15,12 @@ namespace Orb.Models.Events.Backfills; /// backfill. The response also includes [`pagination_metadata`](/api-reference/pagination), /// which lets the caller retrieve the next page of results if they exist. More information /// about pagination can be found in the [Pagination-metadata schema](pagination). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BackfillListParams : ParamsBase +public record class BackfillListParams : ParamsBase { /// /// Cursor for pagination. This can be populated by the `next_cursor` value returned @@ -55,8 +59,11 @@ public long? Limit public BackfillListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BackfillListParams(BackfillListParams backfillListParams) : base(backfillListParams) { } +#pragma warning restore CS8618 public BackfillListParams( IReadOnlyDictionary rawHeaderData, @@ -91,6 +98,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BackfillListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/events/backfills") @@ -107,4 +134,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Events/Backfills/BackfillRevertParams.cs b/src/Orb/Models/Events/Backfills/BackfillRevertParams.cs index 5aaaacb0..5c37076b 100644 --- a/src/Orb/Models/Events/Backfills/BackfillRevertParams.cs +++ b/src/Orb/Models/Events/Backfills/BackfillRevertParams.cs @@ -16,18 +16,25 @@ namespace Orb.Models.Events.Backfills; /// /// If a backfill is reverted before its closed, no usage will be updated as /// a result of the backfill and it will immediately transition to `reverted`. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BackfillRevertParams : ParamsBase +public record class BackfillRevertParams : ParamsBase { public string? BackfillID { get; init; } public BackfillRevertParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BackfillRevertParams(BackfillRevertParams backfillRevertParams) : base(backfillRevertParams) { this.BackfillID = backfillRevertParams.BackfillID; } +#pragma warning restore CS8618 public BackfillRevertParams( IReadOnlyDictionary rawHeaderData, @@ -62,6 +69,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["BackfillID"] = this.BackfillID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BackfillRevertParams? other) + { + if (other == null) + { + return false; + } + return (this.BackfillID?.Equals(other.BackfillID) ?? other.BackfillID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -81,4 +110,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Events/EventDeprecateParams.cs b/src/Orb/Models/Events/EventDeprecateParams.cs index 59cac2ff..7354a41b 100644 --- a/src/Orb/Models/Events/EventDeprecateParams.cs +++ b/src/Orb/Models/Events/EventDeprecateParams.cs @@ -42,18 +42,25 @@ namespace Orb.Models.Events; /// events for customers not in the Orb system. * By default, no more than 100 events /// can be deprecated for a single customer in a 100 day period. For higher volume /// updates, consider using the [event backfill](create-backfill) endpoint. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class EventDeprecateParams : ParamsBase +public record class EventDeprecateParams : ParamsBase { public string? EventID { get; init; } public EventDeprecateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventDeprecateParams(EventDeprecateParams eventDeprecateParams) : base(eventDeprecateParams) { this.EventID = eventDeprecateParams.EventID; } +#pragma warning restore CS8618 public EventDeprecateParams( IReadOnlyDictionary rawHeaderData, @@ -88,6 +95,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["EventID"] = this.EventID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(EventDeprecateParams? other) + { + if (other == null) + { + return false; + } + return (this.EventID?.Equals(other.EventID) ?? other.EventID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -107,4 +136,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Events/EventIngestParams.cs b/src/Orb/Models/Events/EventIngestParams.cs index dc9ebda8..04b688ba 100644 --- a/src/Orb/Models/Events/EventIngestParams.cs +++ b/src/Orb/Models/Events/EventIngestParams.cs @@ -175,8 +175,12 @@ namespace Orb.Models.Events; /// #### Example: ingestion response with `debug=false` /// /// ```json { "validation_failed": [] } ``` +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class EventIngestParams : ParamsBase +public record class EventIngestParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -237,11 +241,14 @@ public bool? Debug public EventIngestParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventIngestParams(EventIngestParams eventIngestParams) : base(eventIngestParams) { this._rawBodyData = new(eventIngestParams._rawBodyData); } +#pragma warning restore CS8618 public EventIngestParams( IReadOnlyDictionary rawHeaderData, @@ -282,6 +289,28 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(EventIngestParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/ingest") @@ -307,6 +336,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(JsonModelConverter))] diff --git a/src/Orb/Models/Events/EventSearchParams.cs b/src/Orb/Models/Events/EventSearchParams.cs index 9dc0f984..7d9a29f1 100644 --- a/src/Orb/Models/Events/EventSearchParams.cs +++ b/src/Orb/Models/Events/EventSearchParams.cs @@ -25,8 +25,12 @@ namespace Orb.Models.Events; /// /// By default, Orb will not throw a `404` if no events matched, Orb will return /// an empty array for `data` instead. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class EventSearchParams : ParamsBase +public record class EventSearchParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -86,11 +90,14 @@ public DateTimeOffset? TimeframeStart public EventSearchParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventSearchParams(EventSearchParams eventSearchParams) : base(eventSearchParams) { this._rawBodyData = new(eventSearchParams._rawBodyData); } +#pragma warning restore CS8618 public EventSearchParams( IReadOnlyDictionary rawHeaderData, @@ -131,6 +138,28 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(EventSearchParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/events/search") @@ -156,4 +185,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Events/EventUpdateParams.cs b/src/Orb/Models/Events/EventUpdateParams.cs index 05eb52a7..2a935ae4 100644 --- a/src/Orb/Models/Events/EventUpdateParams.cs +++ b/src/Orb/Models/Events/EventUpdateParams.cs @@ -48,8 +48,12 @@ namespace Orb.Models.Events; /// previous billing period. * By default, no more than 100 events can be amended /// for a single customer in a 100 day period. For higher volume updates, consider /// using the [event backfill](create-backfill) endpoint. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class EventUpdateParams : ParamsBase +public record class EventUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -137,6 +141,8 @@ public string? ExternalCustomerID public EventUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventUpdateParams(EventUpdateParams eventUpdateParams) : base(eventUpdateParams) { @@ -144,6 +150,7 @@ public EventUpdateParams(EventUpdateParams eventUpdateParams) this._rawBodyData = new(eventUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public EventUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -184,6 +191,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["EventID"] = this.EventID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(EventUpdateParams? other) + { + if (other == null) + { + return false; + } + return (this.EventID?.Equals(other.EventID) ?? other.EventID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -211,4 +242,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Events/Volume/EventVolumes.cs b/src/Orb/Models/Events/Volume/EventVolumes.cs index 617b5f4d..bd74c288 100644 --- a/src/Orb/Models/Events/Volume/EventVolumes.cs +++ b/src/Orb/Models/Events/Volume/EventVolumes.cs @@ -12,21 +12,16 @@ namespace Orb.Models.Events.Volume; [JsonConverter(typeof(JsonModelConverter))] public sealed record class EventVolumes : JsonModel { - public required IReadOnlyList Data + public required IReadOnlyList Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("data"); + return this._rawData.GetNotNullStruct>("data"); } init { - this._rawData.Set>( - "data", - ImmutableArray.ToImmutableArray(value) - ); + this._rawData.Set>("data", ImmutableArray.ToImmutableArray(value)); } } @@ -64,7 +59,7 @@ public static EventVolumes FromRawUnchecked(IReadOnlyDictionary data) + public EventVolumes(IReadOnlyList data) : this() { this.Data = data; @@ -82,12 +77,7 @@ public EventVolumes FromRawUnchecked(IReadOnlyDictionary ra /// An EventVolume contains the event volume ingested in an hourly window. The timestamp /// used for the aggregation is the `timestamp` datetime field on events. /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Events.Volume.Data, - global::Orb.Models.Events.Volume.DataFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Data : JsonModel { /// @@ -133,7 +123,7 @@ public override void Validate() public Data() { } - public Data(global::Orb.Models.Events.Volume.Data data) + public Data(Data data) : base(data) { } public Data(IReadOnlyDictionary rawData) @@ -149,19 +139,16 @@ public Data(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Events.Volume.Data FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Data FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class DataFromRaw : IFromRawJson +class DataFromRaw : IFromRawJson { /// - public global::Orb.Models.Events.Volume.Data FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Events.Volume.Data.FromRawUnchecked(rawData); + public Data FromRawUnchecked(IReadOnlyDictionary rawData) => + Data.FromRawUnchecked(rawData); } diff --git a/src/Orb/Models/Events/Volume/VolumeListParams.cs b/src/Orb/Models/Events/Volume/VolumeListParams.cs index eec55f97..8ab168de 100644 --- a/src/Orb/Models/Events/Volume/VolumeListParams.cs +++ b/src/Orb/Models/Events/Volume/VolumeListParams.cs @@ -20,8 +20,12 @@ namespace Orb.Models.Events.Volume; /// hour where the start and end time are hour-aligned and in UTC. When a specific /// timestamp is passed in for either start or end time, the response includes the /// hours the timestamp falls in. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class VolumeListParams : ParamsBase +public record class VolumeListParams : ParamsBase { /// /// The start of the timeframe, inclusive, in which to return event volume. All @@ -99,8 +103,11 @@ public DateTimeOffset? TimeframeEnd public VolumeListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public VolumeListParams(VolumeListParams volumeListParams) : base(volumeListParams) { } +#pragma warning restore CS8618 public VolumeListParams( IReadOnlyDictionary rawHeaderData, @@ -135,6 +142,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(VolumeListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/events/volume") @@ -151,4 +178,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateParams.cs b/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateParams.cs index 2604e2c9..c431ae91 100644 --- a/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateParams.cs +++ b/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateParams.cs @@ -21,8 +21,12 @@ namespace Orb.Models.InvoiceLineItems; /// for the line item. - If both `item_id` and `name` are provided: The item is looked /// up by ID for association, but the provided `name` is used for the line item /// (not the item's name). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvoiceLineItemCreateParams : ParamsBase +public record class InvoiceLineItemCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -131,11 +135,14 @@ public string? Name public InvoiceLineItemCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceLineItemCreateParams(InvoiceLineItemCreateParams invoiceLineItemCreateParams) : base(invoiceLineItemCreateParams) { this._rawBodyData = new(invoiceLineItemCreateParams._rawBodyData); } +#pragma warning restore CS8618 public InvoiceLineItemCreateParams( IReadOnlyDictionary rawHeaderData, @@ -176,6 +183,28 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InvoiceLineItemCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/invoice_line_items") @@ -201,4 +230,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs b/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs index 8e2e5450..d34fc7c7 100644 --- a/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs +++ b/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs @@ -47,18 +47,16 @@ public required string AdjustedSubtotal /// on invoice calculations (ie. usage discounts -> amount discounts -> percentage /// discounts -> minimums -> maximums). /// - public required IReadOnlyList Adjustments + public required IReadOnlyList Adjustments { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("adjustments"); + return this._rawData.GetNotNullStruct>("adjustments"); } init { - this._rawData.Set>( + this._rawData.Set>( "adjustments", ImmutableArray.ToImmutableArray(value) ); @@ -210,18 +208,16 @@ public required double Quantity /// For complex pricing structures, the line item can be broken down further /// in `sub_line_items`. /// - public required IReadOnlyList SubLineItems + public required IReadOnlyList SubLineItems { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("sub_line_items"); + return this._rawData.GetNotNullStruct>("sub_line_items"); } init { - this._rawData.Set>( + this._rawData.Set>( "sub_line_items", ImmutableArray.ToImmutableArray(value) ); @@ -348,7 +344,7 @@ IReadOnlyDictionary rawData ) => InvoiceLineItemCreateResponse.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.InvoiceLineItems.AdjustmentConverter))] +[JsonConverter(typeof(AdjustmentConverter))] public record class Adjustment : ModelBase { public object? Value { get; } = null; @@ -678,25 +674,17 @@ public T Match( }; } - public static implicit operator global::Orb.Models.InvoiceLineItems.Adjustment( - MonetaryUsageDiscountAdjustment value - ) => new(value); + public static implicit operator Adjustment(MonetaryUsageDiscountAdjustment value) => new(value); - public static implicit operator global::Orb.Models.InvoiceLineItems.Adjustment( - MonetaryAmountDiscountAdjustment value - ) => new(value); + public static implicit operator Adjustment(MonetaryAmountDiscountAdjustment value) => + new(value); - public static implicit operator global::Orb.Models.InvoiceLineItems.Adjustment( - MonetaryPercentageDiscountAdjustment value - ) => new(value); + public static implicit operator Adjustment(MonetaryPercentageDiscountAdjustment value) => + new(value); - public static implicit operator global::Orb.Models.InvoiceLineItems.Adjustment( - MonetaryMinimumAdjustment value - ) => new(value); + public static implicit operator Adjustment(MonetaryMinimumAdjustment value) => new(value); - public static implicit operator global::Orb.Models.InvoiceLineItems.Adjustment( - MonetaryMaximumAdjustment value - ) => new(value); + public static implicit operator Adjustment(MonetaryMaximumAdjustment value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -723,7 +711,7 @@ public override void Validate() ); } - public virtual bool Equals(global::Orb.Models.InvoiceLineItems.Adjustment? other) + public virtual bool Equals(Adjustment? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -737,9 +725,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class AdjustmentConverter : JsonConverter +sealed class AdjustmentConverter : JsonConverter { - public override global::Orb.Models.InvoiceLineItems.Adjustment? Read( + public override Adjustment? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -871,14 +859,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.InvoiceLineItems.Adjustment(element); + return new Adjustment(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.InvoiceLineItems.Adjustment value, + Adjustment value, JsonSerializerOptions options ) { @@ -886,7 +874,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.InvoiceLineItems.SubLineItemConverter))] +[JsonConverter(typeof(SubLineItemConverter))] public record class SubLineItem : ModelBase { public object? Value { get; } = null; @@ -1107,17 +1095,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.InvoiceLineItems.SubLineItem( - MatrixSubLineItem value - ) => new(value); + public static implicit operator SubLineItem(MatrixSubLineItem value) => new(value); - public static implicit operator global::Orb.Models.InvoiceLineItems.SubLineItem( - TierSubLineItem value - ) => new(value); + public static implicit operator SubLineItem(TierSubLineItem value) => new(value); - public static implicit operator global::Orb.Models.InvoiceLineItems.SubLineItem( - OtherSubLineItem value - ) => new(value); + public static implicit operator SubLineItem(OtherSubLineItem value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -1142,7 +1124,7 @@ public override void Validate() ); } - public virtual bool Equals(global::Orb.Models.InvoiceLineItems.SubLineItem? other) + public virtual bool Equals(SubLineItem? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -1156,9 +1138,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class SubLineItemConverter : JsonConverter +sealed class SubLineItemConverter : JsonConverter { - public override global::Orb.Models.InvoiceLineItems.SubLineItem? Read( + public override SubLineItem? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1245,14 +1227,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.InvoiceLineItems.SubLineItem(element); + return new SubLineItem(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.InvoiceLineItems.SubLineItem value, + SubLineItem value, JsonSerializerOptions options ) { diff --git a/src/Orb/Models/Invoices/InvoiceCreateParams.cs b/src/Orb/Models/Invoices/InvoiceCreateParams.cs index c572f34f..e78d79d3 100644 --- a/src/Orb/Models/Invoices/InvoiceCreateParams.cs +++ b/src/Orb/Models/Invoices/InvoiceCreateParams.cs @@ -14,8 +14,12 @@ namespace Orb.Models.Invoices; /// /// This endpoint is used to create a one-off invoice for a customer. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvoiceCreateParams : ParamsBase +public record class InvoiceCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -51,18 +55,16 @@ public required string Currency init { this._rawBodyData.Set("invoice_date", value); } } - public required IReadOnlyList LineItems + public required IReadOnlyList LineItems { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNotNullStruct< - ImmutableArray - >("line_items"); + return this._rawBodyData.GetNotNullStruct>("line_items"); } init { - this._rawBodyData.Set>( + this._rawBodyData.Set>( "line_items", ImmutableArray.ToImmutableArray(value) ); @@ -204,11 +206,14 @@ public bool? WillAutoIssue public InvoiceCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceCreateParams(InvoiceCreateParams invoiceCreateParams) : base(invoiceCreateParams) { this._rawBodyData = new(invoiceCreateParams._rawBodyData); } +#pragma warning restore CS8618 public InvoiceCreateParams( IReadOnlyDictionary rawHeaderData, @@ -249,6 +254,28 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InvoiceCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/invoices") @@ -274,14 +301,14 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Invoices.LineItem, - global::Orb.Models.Invoices.LineItemFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class LineItem : JsonModel { /// @@ -307,14 +334,12 @@ public required string ItemID init { this._rawData.Set("item_id", value); } } - public required ApiEnum ModelType + public required ApiEnum ModelType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("model_type"); + return this._rawData.GetNotNullClass>("model_type"); } init { this._rawData.Set("model_type", value); } } @@ -385,7 +410,7 @@ public override void Validate() public LineItem() { } - public LineItem(global::Orb.Models.Invoices.LineItem lineItem) + public LineItem(LineItem lineItem) : base(lineItem) { } public LineItem(IReadOnlyDictionary rawData) @@ -401,32 +426,29 @@ public LineItem(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Invoices.LineItem FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static LineItem FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class LineItemFromRaw : IFromRawJson +class LineItemFromRaw : IFromRawJson { /// - public global::Orb.Models.Invoices.LineItem FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Invoices.LineItem.FromRawUnchecked(rawData); + public LineItem FromRawUnchecked(IReadOnlyDictionary rawData) => + LineItem.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Invoices.ModelTypeConverter))] +[JsonConverter(typeof(ModelTypeConverter))] public enum ModelType { Unit, } -sealed class ModelTypeConverter : JsonConverter +sealed class ModelTypeConverter : JsonConverter { - public override global::Orb.Models.Invoices.ModelType Read( + public override ModelType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -434,14 +456,14 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "unit" => global::Orb.Models.Invoices.ModelType.Unit, - _ => (global::Orb.Models.Invoices.ModelType)(-1), + "unit" => ModelType.Unit, + _ => (ModelType)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Invoices.ModelType value, + ModelType value, JsonSerializerOptions options ) { @@ -449,7 +471,7 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Invoices.ModelType.Unit => "unit", + ModelType.Unit => "unit", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Invoices/InvoiceDeleteLineItemParams.cs b/src/Orb/Models/Invoices/InvoiceDeleteLineItemParams.cs index 526c14b1..3fc2cdbf 100644 --- a/src/Orb/Models/Invoices/InvoiceDeleteLineItemParams.cs +++ b/src/Orb/Models/Invoices/InvoiceDeleteLineItemParams.cs @@ -13,8 +13,12 @@ namespace Orb.Models.Invoices; /// /// This endpoint only allows deletion of one-off line items (not subscription-based /// line items). The invoice must be in a draft status for this operation to succeed. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvoiceDeleteLineItemParams : ParamsBase +public record class InvoiceDeleteLineItemParams : ParamsBase { public required string InvoiceID { get; init; } @@ -22,12 +26,15 @@ public sealed record class InvoiceDeleteLineItemParams : ParamsBase public InvoiceDeleteLineItemParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceDeleteLineItemParams(InvoiceDeleteLineItemParams invoiceDeleteLineItemParams) : base(invoiceDeleteLineItemParams) { this.InvoiceID = invoiceDeleteLineItemParams.InvoiceID; this.LineItemID = invoiceDeleteLineItemParams.LineItemID; } +#pragma warning restore CS8618 public InvoiceDeleteLineItemParams( IReadOnlyDictionary rawHeaderData, @@ -62,6 +69,30 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["InvoiceID"] = this.InvoiceID, + ["LineItemID"] = this.LineItemID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InvoiceDeleteLineItemParams? other) + { + if (other == null) + { + return false; + } + return this.InvoiceID.Equals(other.InvoiceID) + && (this.LineItemID?.Equals(other.LineItemID) ?? other.LineItemID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -85,4 +116,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Invoices/InvoiceFetchParams.cs b/src/Orb/Models/Invoices/InvoiceFetchParams.cs index 563df22d..f9ad0653 100644 --- a/src/Orb/Models/Invoices/InvoiceFetchParams.cs +++ b/src/Orb/Models/Invoices/InvoiceFetchParams.cs @@ -10,18 +10,25 @@ namespace Orb.Models.Invoices; /// /// This endpoint is used to fetch an [`Invoice`](/core-concepts#invoice) given an identifier. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvoiceFetchParams : ParamsBase +public record class InvoiceFetchParams : ParamsBase { public string? InvoiceID { get; init; } public InvoiceFetchParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceFetchParams(InvoiceFetchParams invoiceFetchParams) : base(invoiceFetchParams) { this.InvoiceID = invoiceFetchParams.InvoiceID; } +#pragma warning restore CS8618 public InvoiceFetchParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["InvoiceID"] = this.InvoiceID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InvoiceFetchParams? other) + { + if (other == null) + { + return false; + } + return (this.InvoiceID?.Equals(other.InvoiceID) ?? other.InvoiceID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -74,4 +103,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Invoices/InvoiceFetchUpcomingParams.cs b/src/Orb/Models/Invoices/InvoiceFetchUpcomingParams.cs index 193ec1bf..9ee83d4a 100644 --- a/src/Orb/Models/Invoices/InvoiceFetchUpcomingParams.cs +++ b/src/Orb/Models/Invoices/InvoiceFetchUpcomingParams.cs @@ -11,8 +11,12 @@ namespace Orb.Models.Invoices; /// /// This endpoint can be used to fetch the upcoming [invoice](/core-concepts#invoice) /// for the current billing period given a subscription. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvoiceFetchUpcomingParams : ParamsBase +public record class InvoiceFetchUpcomingParams : ParamsBase { public required string SubscriptionID { @@ -26,8 +30,11 @@ public required string SubscriptionID public InvoiceFetchUpcomingParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceFetchUpcomingParams(InvoiceFetchUpcomingParams invoiceFetchUpcomingParams) : base(invoiceFetchUpcomingParams) { } +#pragma warning restore CS8618 public InvoiceFetchUpcomingParams( IReadOnlyDictionary rawHeaderData, @@ -62,6 +69,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InvoiceFetchUpcomingParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/invoices/upcoming") @@ -78,4 +105,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs b/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs index 01a532f8..a398e2e8 100644 --- a/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs +++ b/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs @@ -39,14 +39,12 @@ public required string AmountDue init { this._rawData.Set("amount_due", value); } } - public required global::Orb.Models.Invoices.AutoCollection AutoCollection + public required AutoCollection AutoCollection { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "auto_collection" - ); + return this._rawData.GetNotNullClass("auto_collection"); } init { this._rawData.Set("auto_collection", value); } } @@ -77,18 +75,16 @@ public required Address? BillingAddress /// /// A list of credit notes associated with the invoice /// - public required IReadOnlyList CreditNotes + public required IReadOnlyList CreditNotes { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("credit_notes"); + return this._rawData.GetNotNullStruct>("credit_notes"); } init { - this._rawData.Set>( + this._rawData.Set>( "credit_notes", ImmutableArray.ToImmutableArray(value) ); @@ -118,20 +114,21 @@ public required CustomerMinified Customer init { this._rawData.Set("customer", value); } } - public required IReadOnlyList CustomerBalanceTransactions + public required IReadOnlyList CustomerBalanceTransactions { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("customer_balance_transactions"); + return this._rawData.GetNotNullStruct>( + "customer_balance_transactions" + ); } init { - this._rawData.Set< - ImmutableArray - >("customer_balance_transactions", ImmutableArray.ToImmutableArray(value)); + this._rawData.Set>( + "customer_balance_transactions", + ImmutableArray.ToImmutableArray(value) + ); } } @@ -355,14 +352,12 @@ public required string? InvoicePdf init { this._rawData.Set("invoice_pdf", value); } } - public required ApiEnum InvoiceSource + public required ApiEnum InvoiceSource { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("invoice_source"); + return this._rawData.GetNotNullClass>("invoice_source"); } init { this._rawData.Set("invoice_source", value); } } @@ -508,18 +503,18 @@ public required string? MinimumAmount /// /// A list of payment attempts associated with the invoice /// - public required IReadOnlyList PaymentAttempts + public required IReadOnlyList PaymentAttempts { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("payment_attempts"); + return this._rawData.GetNotNullStruct>( + "payment_attempts" + ); } init { - this._rawData.Set>( + this._rawData.Set>( "payment_attempts", ImmutableArray.ToImmutableArray(value) ); @@ -783,12 +778,7 @@ IReadOnlyDictionary rawData ) => InvoiceFetchUpcomingResponse.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Invoices.AutoCollection, - global::Orb.Models.Invoices.AutoCollectionFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class AutoCollection : JsonModel { /// @@ -863,7 +853,7 @@ public override void Validate() public AutoCollection() { } - public AutoCollection(global::Orb.Models.Invoices.AutoCollection autoCollection) + public AutoCollection(AutoCollection autoCollection) : base(autoCollection) { } public AutoCollection(IReadOnlyDictionary rawData) @@ -879,29 +869,21 @@ public AutoCollection(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Invoices.AutoCollection FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static AutoCollection FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class AutoCollectionFromRaw : IFromRawJson +class AutoCollectionFromRaw : IFromRawJson { /// - public global::Orb.Models.Invoices.AutoCollection FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Invoices.AutoCollection.FromRawUnchecked(rawData); + public AutoCollection FromRawUnchecked(IReadOnlyDictionary rawData) => + AutoCollection.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Invoices.CreditNote, - global::Orb.Models.Invoices.CreditNoteFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class CreditNote : JsonModel { public required string ID @@ -995,7 +977,7 @@ public override void Validate() public CreditNote() { } - public CreditNote(global::Orb.Models.Invoices.CreditNote creditNote) + public CreditNote(CreditNote creditNote) : base(creditNote) { } public CreditNote(IReadOnlyDictionary rawData) @@ -1011,28 +993,22 @@ public CreditNote(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Invoices.CreditNote FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static CreditNote FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class CreditNoteFromRaw : IFromRawJson +class CreditNoteFromRaw : IFromRawJson { /// - public global::Orb.Models.Invoices.CreditNote FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Invoices.CreditNote.FromRawUnchecked(rawData); + public CreditNote FromRawUnchecked(IReadOnlyDictionary rawData) => + CreditNote.FromRawUnchecked(rawData); } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Invoices.CustomerBalanceTransaction, - global::Orb.Models.Invoices.CustomerBalanceTransactionFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class CustomerBalanceTransaction : JsonModel { @@ -1049,14 +1025,12 @@ public required string ID init { this._rawData.Set("id", value); } } - public required ApiEnum Action + public required ApiEnum Action { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("action"); + return this._rawData.GetNotNullClass>("action"); } init { this._rawData.Set("action", value); } } @@ -1176,9 +1150,7 @@ public override void Validate() public CustomerBalanceTransaction() { } - public CustomerBalanceTransaction( - global::Orb.Models.Invoices.CustomerBalanceTransaction customerBalanceTransaction - ) + public CustomerBalanceTransaction(CustomerBalanceTransaction customerBalanceTransaction) : base(customerBalanceTransaction) { } public CustomerBalanceTransaction(IReadOnlyDictionary rawData) @@ -1194,8 +1166,8 @@ public CustomerBalanceTransaction(IReadOnlyDictionary rawDa } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Invoices.CustomerBalanceTransaction FromRawUnchecked( + /// + public static CustomerBalanceTransaction FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -1203,16 +1175,15 @@ IReadOnlyDictionary rawData } } -class CustomerBalanceTransactionFromRaw - : IFromRawJson +class CustomerBalanceTransactionFromRaw : IFromRawJson { /// - public global::Orb.Models.Invoices.CustomerBalanceTransaction FromRawUnchecked( + public CustomerBalanceTransaction FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Invoices.CustomerBalanceTransaction.FromRawUnchecked(rawData); + ) => CustomerBalanceTransaction.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Invoices.ActionConverter))] +[JsonConverter(typeof(ActionConverter))] public enum Action { AppliedToInvoice, @@ -1227,9 +1198,9 @@ public enum Action SmallInvoiceCarryover, } -sealed class ActionConverter : JsonConverter +sealed class ActionConverter : JsonConverter { - public override global::Orb.Models.Invoices.Action Read( + public override Action Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1237,41 +1208,36 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "applied_to_invoice" => global::Orb.Models.Invoices.Action.AppliedToInvoice, - "manual_adjustment" => global::Orb.Models.Invoices.Action.ManualAdjustment, - "prorated_refund" => global::Orb.Models.Invoices.Action.ProratedRefund, - "revert_prorated_refund" => global::Orb.Models.Invoices.Action.RevertProratedRefund, - "return_from_voiding" => global::Orb.Models.Invoices.Action.ReturnFromVoiding, - "credit_note_applied" => global::Orb.Models.Invoices.Action.CreditNoteApplied, - "credit_note_voided" => global::Orb.Models.Invoices.Action.CreditNoteVoided, - "overpayment_refund" => global::Orb.Models.Invoices.Action.OverpaymentRefund, - "external_payment" => global::Orb.Models.Invoices.Action.ExternalPayment, - "small_invoice_carryover" => global::Orb.Models.Invoices.Action.SmallInvoiceCarryover, - _ => (global::Orb.Models.Invoices.Action)(-1), + "applied_to_invoice" => Action.AppliedToInvoice, + "manual_adjustment" => Action.ManualAdjustment, + "prorated_refund" => Action.ProratedRefund, + "revert_prorated_refund" => Action.RevertProratedRefund, + "return_from_voiding" => Action.ReturnFromVoiding, + "credit_note_applied" => Action.CreditNoteApplied, + "credit_note_voided" => Action.CreditNoteVoided, + "overpayment_refund" => Action.OverpaymentRefund, + "external_payment" => Action.ExternalPayment, + "small_invoice_carryover" => Action.SmallInvoiceCarryover, + _ => (Action)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Invoices.Action value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Action value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Invoices.Action.AppliedToInvoice => "applied_to_invoice", - global::Orb.Models.Invoices.Action.ManualAdjustment => "manual_adjustment", - global::Orb.Models.Invoices.Action.ProratedRefund => "prorated_refund", - global::Orb.Models.Invoices.Action.RevertProratedRefund => "revert_prorated_refund", - global::Orb.Models.Invoices.Action.ReturnFromVoiding => "return_from_voiding", - global::Orb.Models.Invoices.Action.CreditNoteApplied => "credit_note_applied", - global::Orb.Models.Invoices.Action.CreditNoteVoided => "credit_note_voided", - global::Orb.Models.Invoices.Action.OverpaymentRefund => "overpayment_refund", - global::Orb.Models.Invoices.Action.ExternalPayment => "external_payment", - global::Orb.Models.Invoices.Action.SmallInvoiceCarryover => - "small_invoice_carryover", + Action.AppliedToInvoice => "applied_to_invoice", + Action.ManualAdjustment => "manual_adjustment", + Action.ProratedRefund => "prorated_refund", + Action.RevertProratedRefund => "revert_prorated_refund", + Action.ReturnFromVoiding => "return_from_voiding", + Action.CreditNoteApplied => "credit_note_applied", + Action.CreditNoteVoided => "credit_note_voided", + Action.OverpaymentRefund => "overpayment_refund", + Action.ExternalPayment => "external_payment", + Action.SmallInvoiceCarryover => "small_invoice_carryover", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -1281,7 +1247,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.Invoices.TypeConverter))] +[JsonConverter(typeof(TypeConverter))] public enum Type { Increment, @@ -1325,7 +1291,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.Invoices.InvoiceSourceConverter))] +[JsonConverter(typeof(InvoiceSourceConverter))] public enum InvoiceSource { Subscription, @@ -1333,9 +1299,9 @@ public enum InvoiceSource OneOff, } -sealed class InvoiceSourceConverter : JsonConverter +sealed class InvoiceSourceConverter : JsonConverter { - public override global::Orb.Models.Invoices.InvoiceSource Read( + public override InvoiceSource Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1343,16 +1309,16 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "subscription" => global::Orb.Models.Invoices.InvoiceSource.Subscription, - "partial" => global::Orb.Models.Invoices.InvoiceSource.Partial, - "one_off" => global::Orb.Models.Invoices.InvoiceSource.OneOff, - _ => (global::Orb.Models.Invoices.InvoiceSource)(-1), + "subscription" => InvoiceSource.Subscription, + "partial" => InvoiceSource.Partial, + "one_off" => InvoiceSource.OneOff, + _ => (InvoiceSource)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Invoices.InvoiceSource value, + InvoiceSource value, JsonSerializerOptions options ) { @@ -1360,9 +1326,9 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Invoices.InvoiceSource.Subscription => "subscription", - global::Orb.Models.Invoices.InvoiceSource.Partial => "partial", - global::Orb.Models.Invoices.InvoiceSource.OneOff => "one_off", + InvoiceSource.Subscription => "subscription", + InvoiceSource.Partial => "partial", + InvoiceSource.OneOff => "one_off", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -1412,18 +1378,16 @@ public required string AdjustedSubtotal /// on invoice calculations (ie. usage discounts -> amount discounts -> percentage /// discounts -> minimums -> maximums). /// - public required IReadOnlyList Adjustments + public required IReadOnlyList Adjustments { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("adjustments"); + return this._rawData.GetNotNullStruct>("adjustments"); } init { - this._rawData.Set>( + this._rawData.Set>( "adjustments", ImmutableArray.ToImmutableArray(value) ); @@ -1575,18 +1539,16 @@ public required double Quantity /// For complex pricing structures, the line item can be broken down further /// in `sub_line_items`. /// - public required IReadOnlyList SubLineItems + public required IReadOnlyList SubLineItems { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("sub_line_items"); + return this._rawData.GetNotNullStruct>("sub_line_items"); } init { - this._rawData.Set>( + this._rawData.Set>( "sub_line_items", ImmutableArray.ToImmutableArray(value) ); @@ -1714,7 +1676,7 @@ IReadOnlyDictionary rawData ) => InvoiceFetchUpcomingResponseLineItem.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Invoices.AdjustmentConverter))] +[JsonConverter(typeof(AdjustmentConverter))] public record class Adjustment : ModelBase { public object? Value { get; } = null; @@ -2044,25 +2006,17 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Invoices.Adjustment( - MonetaryUsageDiscountAdjustment value - ) => new(value); + public static implicit operator Adjustment(MonetaryUsageDiscountAdjustment value) => new(value); - public static implicit operator global::Orb.Models.Invoices.Adjustment( - MonetaryAmountDiscountAdjustment value - ) => new(value); + public static implicit operator Adjustment(MonetaryAmountDiscountAdjustment value) => + new(value); - public static implicit operator global::Orb.Models.Invoices.Adjustment( - MonetaryPercentageDiscountAdjustment value - ) => new(value); + public static implicit operator Adjustment(MonetaryPercentageDiscountAdjustment value) => + new(value); - public static implicit operator global::Orb.Models.Invoices.Adjustment( - MonetaryMinimumAdjustment value - ) => new(value); + public static implicit operator Adjustment(MonetaryMinimumAdjustment value) => new(value); - public static implicit operator global::Orb.Models.Invoices.Adjustment( - MonetaryMaximumAdjustment value - ) => new(value); + public static implicit operator Adjustment(MonetaryMaximumAdjustment value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2089,7 +2043,7 @@ public override void Validate() ); } - public virtual bool Equals(global::Orb.Models.Invoices.Adjustment? other) + public virtual bool Equals(Adjustment? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -2103,9 +2057,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class AdjustmentConverter : JsonConverter +sealed class AdjustmentConverter : JsonConverter { - public override global::Orb.Models.Invoices.Adjustment? Read( + public override Adjustment? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -2237,14 +2191,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Invoices.Adjustment(element); + return new Adjustment(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Invoices.Adjustment value, + Adjustment value, JsonSerializerOptions options ) { @@ -2252,7 +2206,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.Invoices.SubLineItemConverter))] +[JsonConverter(typeof(SubLineItemConverter))] public record class SubLineItem : ModelBase { public object? Value { get; } = null; @@ -2473,17 +2427,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Invoices.SubLineItem( - MatrixSubLineItem value - ) => new(value); + public static implicit operator SubLineItem(MatrixSubLineItem value) => new(value); - public static implicit operator global::Orb.Models.Invoices.SubLineItem( - TierSubLineItem value - ) => new(value); + public static implicit operator SubLineItem(TierSubLineItem value) => new(value); - public static implicit operator global::Orb.Models.Invoices.SubLineItem( - OtherSubLineItem value - ) => new(value); + public static implicit operator SubLineItem(OtherSubLineItem value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2508,7 +2456,7 @@ public override void Validate() ); } - public virtual bool Equals(global::Orb.Models.Invoices.SubLineItem? other) + public virtual bool Equals(SubLineItem? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -2522,9 +2470,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class SubLineItemConverter : JsonConverter +sealed class SubLineItemConverter : JsonConverter { - public override global::Orb.Models.Invoices.SubLineItem? Read( + public override SubLineItem? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -2611,14 +2559,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Invoices.SubLineItem(element); + return new SubLineItem(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Invoices.SubLineItem value, + SubLineItem value, JsonSerializerOptions options ) { @@ -2626,12 +2574,7 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Invoices.PaymentAttempt, - global::Orb.Models.Invoices.PaymentAttemptFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class PaymentAttempt : JsonModel { /// @@ -2676,14 +2619,14 @@ public required string Amount /// /// The payment provider that attempted to collect the payment. /// - public required ApiEnum? PaymentProvider + public required ApiEnum? PaymentProvider { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass< - ApiEnum - >("payment_provider"); + return this._rawData.GetNullableClass>( + "payment_provider" + ); } init { this._rawData.Set("payment_provider", value); } } @@ -2742,7 +2685,7 @@ public override void Validate() public PaymentAttempt() { } - public PaymentAttempt(global::Orb.Models.Invoices.PaymentAttempt paymentAttempt) + public PaymentAttempt(PaymentAttempt paymentAttempt) : base(paymentAttempt) { } public PaymentAttempt(IReadOnlyDictionary rawData) @@ -2758,35 +2701,32 @@ public PaymentAttempt(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Invoices.PaymentAttempt FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static PaymentAttempt FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PaymentAttemptFromRaw : IFromRawJson +class PaymentAttemptFromRaw : IFromRawJson { /// - public global::Orb.Models.Invoices.PaymentAttempt FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Invoices.PaymentAttempt.FromRawUnchecked(rawData); + public PaymentAttempt FromRawUnchecked(IReadOnlyDictionary rawData) => + PaymentAttempt.FromRawUnchecked(rawData); } /// /// The payment provider that attempted to collect the payment. /// -[JsonConverter(typeof(global::Orb.Models.Invoices.PaymentProviderConverter))] +[JsonConverter(typeof(PaymentProviderConverter))] public enum PaymentProvider { Stripe, } -sealed class PaymentProviderConverter : JsonConverter +sealed class PaymentProviderConverter : JsonConverter { - public override global::Orb.Models.Invoices.PaymentProvider Read( + public override PaymentProvider Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -2794,14 +2734,14 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "stripe" => global::Orb.Models.Invoices.PaymentProvider.Stripe, - _ => (global::Orb.Models.Invoices.PaymentProvider)(-1), + "stripe" => PaymentProvider.Stripe, + _ => (PaymentProvider)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Invoices.PaymentProvider value, + PaymentProvider value, JsonSerializerOptions options ) { @@ -2809,7 +2749,7 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Invoices.PaymentProvider.Stripe => "stripe", + PaymentProvider.Stripe => "stripe", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Invoices/InvoiceIssueParams.cs b/src/Orb/Models/Invoices/InvoiceIssueParams.cs index 4a7427ed..f2944617 100644 --- a/src/Orb/Models/Invoices/InvoiceIssueParams.cs +++ b/src/Orb/Models/Invoices/InvoiceIssueParams.cs @@ -15,8 +15,12 @@ namespace Orb.Models.Invoices; /// is a time in the past. Issuing an invoice could possibly trigger side effects, /// some of which could be customer-visible (e.g. sending emails, auto-collecting /// payment, syncing the invoice to external providers, etc). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvoiceIssueParams : ParamsBase +public record class InvoiceIssueParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -53,6 +57,8 @@ public bool? Synchronous public InvoiceIssueParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceIssueParams(InvoiceIssueParams invoiceIssueParams) : base(invoiceIssueParams) { @@ -60,6 +66,7 @@ public InvoiceIssueParams(InvoiceIssueParams invoiceIssueParams) this._rawBodyData = new(invoiceIssueParams._rawBodyData); } +#pragma warning restore CS8618 public InvoiceIssueParams( IReadOnlyDictionary rawHeaderData, @@ -100,6 +107,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["InvoiceID"] = this.InvoiceID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InvoiceIssueParams? other) + { + if (other == null) + { + return false; + } + return (this.InvoiceID?.Equals(other.InvoiceID) ?? other.InvoiceID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -128,4 +159,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Invoices/InvoiceListParams.cs b/src/Orb/Models/Invoices/InvoiceListParams.cs index 3abf3b01..ca97359b 100644 --- a/src/Orb/Models/Invoices/InvoiceListParams.cs +++ b/src/Orb/Models/Invoices/InvoiceListParams.cs @@ -24,8 +24,12 @@ namespace Orb.Models.Invoices; /// When fetching any `draft` invoices, this returns the last-computed invoice /// values for each draft invoice, which may not always be up-to-date since Orb regularly /// refreshes invoices asynchronously. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvoiceListParams : ParamsBase +public record class InvoiceListParams : ParamsBase { public string? Amount { @@ -222,20 +226,21 @@ public long? Limit } } - public IReadOnlyList>? Status + public IReadOnlyList>? Status { get { this._rawQueryData.Freeze(); - return this._rawQueryData.GetNullableStruct< - ImmutableArray> - >("status"); + return this._rawQueryData.GetNullableStruct>>( + "status" + ); } init { - this._rawQueryData.Set - >?>("status", value == null ? null : ImmutableArray.ToImmutableArray(value)); + this._rawQueryData.Set>?>( + "status", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); } } @@ -251,8 +256,11 @@ public string? SubscriptionID public InvoiceListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceListParams(InvoiceListParams invoiceListParams) : base(invoiceListParams) { } +#pragma warning restore CS8618 public InvoiceListParams( IReadOnlyDictionary rawHeaderData, @@ -287,6 +295,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InvoiceListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/invoices") @@ -303,6 +331,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(DateTypeConverter))] @@ -345,7 +378,7 @@ public override void Write(Utf8JsonWriter writer, DateType value, JsonSerializer } } -[JsonConverter(typeof(global::Orb.Models.Invoices.StatusConverter))] +[JsonConverter(typeof(StatusConverter))] public enum Status { Draft, @@ -355,9 +388,9 @@ public enum Status Void, } -sealed class StatusConverter : JsonConverter +sealed class StatusConverter : JsonConverter { - public override global::Orb.Models.Invoices.Status Read( + public override Status Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -365,30 +398,26 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "draft" => global::Orb.Models.Invoices.Status.Draft, - "issued" => global::Orb.Models.Invoices.Status.Issued, - "paid" => global::Orb.Models.Invoices.Status.Paid, - "synced" => global::Orb.Models.Invoices.Status.Synced, - "void" => global::Orb.Models.Invoices.Status.Void, - _ => (global::Orb.Models.Invoices.Status)(-1), + "draft" => Status.Draft, + "issued" => Status.Issued, + "paid" => Status.Paid, + "synced" => Status.Synced, + "void" => Status.Void, + _ => (Status)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Invoices.Status value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Invoices.Status.Draft => "draft", - global::Orb.Models.Invoices.Status.Issued => "issued", - global::Orb.Models.Invoices.Status.Paid => "paid", - global::Orb.Models.Invoices.Status.Synced => "synced", - global::Orb.Models.Invoices.Status.Void => "void", + Status.Draft => "draft", + Status.Issued => "issued", + Status.Paid => "paid", + Status.Synced => "synced", + Status.Void => "void", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Invoices/InvoiceListSummaryParams.cs b/src/Orb/Models/Invoices/InvoiceListSummaryParams.cs index 72179935..e62a3533 100644 --- a/src/Orb/Models/Invoices/InvoiceListSummaryParams.cs +++ b/src/Orb/Models/Invoices/InvoiceListSummaryParams.cs @@ -27,8 +27,12 @@ namespace Orb.Models.Invoices; /// When fetching any `draft` invoices, this returns the last-computed invoice /// values for each draft invoice, which may not always be up-to-date since Orb regularly /// refreshes invoices asynchronously. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvoiceListSummaryParams : ParamsBase +public record class InvoiceListSummaryParams : ParamsBase { public string? Amount { @@ -227,33 +231,20 @@ public long? Limit } } - public ApiEnum? Status - { - get - { - this._rawQueryData.Freeze(); - return this._rawQueryData.GetNullableClass< - ApiEnum - >("status"); - } - init { this._rawQueryData.Set("status", value); } - } - - public IReadOnlyList>? StatusValue + public IReadOnlyList>? Status { get { this._rawQueryData.Freeze(); return this._rawQueryData.GetNullableStruct< - ImmutableArray> + ImmutableArray> >("status"); } init { - this._rawQueryData.Set>?>( - "status", - value == null ? null : ImmutableArray.ToImmutableArray(value) - ); + this._rawQueryData.Set + >?>("status", value == null ? null : ImmutableArray.ToImmutableArray(value)); } } @@ -269,8 +260,11 @@ public string? SubscriptionID public InvoiceListSummaryParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceListSummaryParams(InvoiceListSummaryParams invoiceListSummaryParams) : base(invoiceListSummaryParams) { } +#pragma warning restore CS8618 public InvoiceListSummaryParams( IReadOnlyDictionary rawHeaderData, @@ -305,6 +299,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InvoiceListSummaryParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/invoices/summary") @@ -321,6 +335,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(InvoiceListSummaryParamsDateTypeConverter))] @@ -420,56 +439,3 @@ JsonSerializerOptions options ); } } - -[JsonConverter(typeof(StatusModelConverter))] -public enum StatusModel -{ - Draft, - Issued, - Paid, - Synced, - Void, -} - -sealed class StatusModelConverter : JsonConverter -{ - public override StatusModel Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "draft" => StatusModel.Draft, - "issued" => StatusModel.Issued, - "paid" => StatusModel.Paid, - "synced" => StatusModel.Synced, - "void" => StatusModel.Void, - _ => (StatusModel)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - StatusModel value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - StatusModel.Draft => "draft", - StatusModel.Issued => "issued", - StatusModel.Paid => "paid", - StatusModel.Synced => "synced", - StatusModel.Void => "void", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} diff --git a/src/Orb/Models/Invoices/InvoiceMarkPaidParams.cs b/src/Orb/Models/Invoices/InvoiceMarkPaidParams.cs index 0dd75ea1..616f3952 100644 --- a/src/Orb/Models/Invoices/InvoiceMarkPaidParams.cs +++ b/src/Orb/Models/Invoices/InvoiceMarkPaidParams.cs @@ -12,8 +12,12 @@ namespace Orb.Models.Invoices; /// /// This endpoint allows an invoice's status to be set to the `paid` status. This /// can only be done to invoices that are in the `issued` or `synced` status. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvoiceMarkPaidParams : ParamsBase +public record class InvoiceMarkPaidParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -64,6 +68,8 @@ public string? Notes public InvoiceMarkPaidParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceMarkPaidParams(InvoiceMarkPaidParams invoiceMarkPaidParams) : base(invoiceMarkPaidParams) { @@ -71,6 +77,7 @@ public InvoiceMarkPaidParams(InvoiceMarkPaidParams invoiceMarkPaidParams) this._rawBodyData = new(invoiceMarkPaidParams._rawBodyData); } +#pragma warning restore CS8618 public InvoiceMarkPaidParams( IReadOnlyDictionary rawHeaderData, @@ -111,6 +118,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["InvoiceID"] = this.InvoiceID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InvoiceMarkPaidParams? other) + { + if (other == null) + { + return false; + } + return (this.InvoiceID?.Equals(other.InvoiceID) ?? other.InvoiceID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -139,4 +170,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Invoices/InvoicePayParams.cs b/src/Orb/Models/Invoices/InvoicePayParams.cs index 58694581..7026e060 100644 --- a/src/Orb/Models/Invoices/InvoicePayParams.cs +++ b/src/Orb/Models/Invoices/InvoicePayParams.cs @@ -11,18 +11,25 @@ namespace Orb.Models.Invoices; /// /// This endpoint collects payment for an invoice using the customer's default payment /// method. This action can only be taken on invoices with status "issued". +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvoicePayParams : ParamsBase +public record class InvoicePayParams : ParamsBase { public string? InvoiceID { get; init; } public InvoicePayParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoicePayParams(InvoicePayParams invoicePayParams) : base(invoicePayParams) { this.InvoiceID = invoicePayParams.InvoiceID; } +#pragma warning restore CS8618 public InvoicePayParams( IReadOnlyDictionary rawHeaderData, @@ -57,6 +64,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["InvoiceID"] = this.InvoiceID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InvoicePayParams? other) + { + if (other == null) + { + return false; + } + return (this.InvoiceID?.Equals(other.InvoiceID) ?? other.InvoiceID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -76,4 +105,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Invoices/InvoiceUpdateParams.cs b/src/Orb/Models/Invoices/InvoiceUpdateParams.cs index f5727977..f7d4c2cb 100644 --- a/src/Orb/Models/Invoices/InvoiceUpdateParams.cs +++ b/src/Orb/Models/Invoices/InvoiceUpdateParams.cs @@ -19,8 +19,12 @@ namespace Orb.Models.Invoices; /// `metadata` can be modified regardless of invoice state. `net_terms`, `due_date`, /// and `invoice_date` can only be modified if the invoice is in a `draft` state. /// `invoice_date` can only be modified for non-subscription invoices. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvoiceUpdateParams : ParamsBase +public record class InvoiceUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -100,6 +104,8 @@ public long? NetTerms public InvoiceUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceUpdateParams(InvoiceUpdateParams invoiceUpdateParams) : base(invoiceUpdateParams) { @@ -107,6 +113,7 @@ public InvoiceUpdateParams(InvoiceUpdateParams invoiceUpdateParams) this._rawBodyData = new(invoiceUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public InvoiceUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -147,6 +154,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["InvoiceID"] = this.InvoiceID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InvoiceUpdateParams? other) + { + if (other == null) + { + return false; + } + return (this.InvoiceID?.Equals(other.InvoiceID) ?? other.InvoiceID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -174,6 +205,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// diff --git a/src/Orb/Models/Invoices/InvoiceVoidParams.cs b/src/Orb/Models/Invoices/InvoiceVoidParams.cs index 63a9c88e..04e8c6a7 100644 --- a/src/Orb/Models/Invoices/InvoiceVoidParams.cs +++ b/src/Orb/Models/Invoices/InvoiceVoidParams.cs @@ -20,18 +20,25 @@ namespace Orb.Models.Invoices; /// If the invoice was used to purchase a credit block, but the invoice is /// not yet paid, the credit block will be voided. If the invoice was created due /// to a top-up, the top-up will be disabled. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvoiceVoidParams : ParamsBase +public record class InvoiceVoidParams : ParamsBase { public string? InvoiceID { get; init; } public InvoiceVoidParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceVoidParams(InvoiceVoidParams invoiceVoidParams) : base(invoiceVoidParams) { this.InvoiceID = invoiceVoidParams.InvoiceID; } +#pragma warning restore CS8618 public InvoiceVoidParams( IReadOnlyDictionary rawHeaderData, @@ -66,6 +73,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["InvoiceID"] = this.InvoiceID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InvoiceVoidParams? other) + { + if (other == null) + { + return false; + } + return (this.InvoiceID?.Equals(other.InvoiceID) ?? other.InvoiceID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -85,4 +114,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Items/ItemArchiveParams.cs b/src/Orb/Models/Items/ItemArchiveParams.cs index 9ae2118a..4b8cf906 100644 --- a/src/Orb/Models/Items/ItemArchiveParams.cs +++ b/src/Orb/Models/Items/ItemArchiveParams.cs @@ -10,18 +10,25 @@ namespace Orb.Models.Items; /// /// Archive item +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ItemArchiveParams : ParamsBase +public record class ItemArchiveParams : ParamsBase { public string? ItemID { get; init; } public ItemArchiveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ItemArchiveParams(ItemArchiveParams itemArchiveParams) : base(itemArchiveParams) { this.ItemID = itemArchiveParams.ItemID; } +#pragma warning restore CS8618 public ItemArchiveParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ItemID"] = this.ItemID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ItemArchiveParams? other) + { + if (other == null) + { + return false; + } + return (this.ItemID?.Equals(other.ItemID) ?? other.ItemID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -75,4 +104,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Items/ItemCreateParams.cs b/src/Orb/Models/Items/ItemCreateParams.cs index 53f15671..d85df2e1 100644 --- a/src/Orb/Models/Items/ItemCreateParams.cs +++ b/src/Orb/Models/Items/ItemCreateParams.cs @@ -11,8 +11,12 @@ namespace Orb.Models.Items; /// /// This endpoint is used to create an [Item](/core-concepts#item). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ItemCreateParams : ParamsBase +public record class ItemCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -58,11 +62,14 @@ public required string Name public ItemCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ItemCreateParams(ItemCreateParams itemCreateParams) : base(itemCreateParams) { this._rawBodyData = new(itemCreateParams._rawBodyData); } +#pragma warning restore CS8618 public ItemCreateParams( IReadOnlyDictionary rawHeaderData, @@ -103,6 +110,28 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ItemCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/items") @@ -128,4 +157,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Items/ItemFetchParams.cs b/src/Orb/Models/Items/ItemFetchParams.cs index cd8f0236..11905422 100644 --- a/src/Orb/Models/Items/ItemFetchParams.cs +++ b/src/Orb/Models/Items/ItemFetchParams.cs @@ -10,18 +10,25 @@ namespace Orb.Models.Items; /// /// This endpoint returns an item identified by its item_id. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ItemFetchParams : ParamsBase +public record class ItemFetchParams : ParamsBase { public string? ItemID { get; init; } public ItemFetchParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ItemFetchParams(ItemFetchParams itemFetchParams) : base(itemFetchParams) { this.ItemID = itemFetchParams.ItemID; } +#pragma warning restore CS8618 public ItemFetchParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ItemID"] = this.ItemID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ItemFetchParams? other) + { + if (other == null) + { + return false; + } + return (this.ItemID?.Equals(other.ItemID) ?? other.ItemID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -74,4 +103,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Items/ItemListParams.cs b/src/Orb/Models/Items/ItemListParams.cs index 5e12608f..d08e7a2e 100644 --- a/src/Orb/Models/Items/ItemListParams.cs +++ b/src/Orb/Models/Items/ItemListParams.cs @@ -10,8 +10,12 @@ namespace Orb.Models.Items; /// /// This endpoint returns a list of all Items, ordered in descending order by creation time. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ItemListParams : ParamsBase +public record class ItemListParams : ParamsBase { /// /// Cursor for pagination. This can be populated by the `next_cursor` value returned @@ -50,8 +54,11 @@ public long? Limit public ItemListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ItemListParams(ItemListParams itemListParams) : base(itemListParams) { } +#pragma warning restore CS8618 public ItemListParams( IReadOnlyDictionary rawHeaderData, @@ -86,6 +93,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ItemListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/items") @@ -102,4 +129,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Items/ItemUpdateParams.cs b/src/Orb/Models/Items/ItemUpdateParams.cs index f2e3552a..68ef65fd 100644 --- a/src/Orb/Models/Items/ItemUpdateParams.cs +++ b/src/Orb/Models/Items/ItemUpdateParams.cs @@ -14,8 +14,12 @@ namespace Orb.Models.Items; /// /// This endpoint can be used to update properties on the Item. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ItemUpdateParams : ParamsBase +public record class ItemUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -78,6 +82,8 @@ public string? Name public ItemUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ItemUpdateParams(ItemUpdateParams itemUpdateParams) : base(itemUpdateParams) { @@ -85,6 +91,7 @@ public ItemUpdateParams(ItemUpdateParams itemUpdateParams) this._rawBodyData = new(itemUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public ItemUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -125,6 +132,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ItemID"] = this.ItemID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ItemUpdateParams? other) + { + if (other == null) + { + return false; + } + return (this.ItemID?.Equals(other.ItemID) ?? other.ItemID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -152,6 +183,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// diff --git a/src/Orb/Models/Metrics/BillableMetric.cs b/src/Orb/Models/Metrics/BillableMetric.cs index b0711a9a..ecd53336 100644 --- a/src/Orb/Models/Metrics/BillableMetric.cs +++ b/src/Orb/Models/Metrics/BillableMetric.cs @@ -85,14 +85,12 @@ public required string Name init { this._rawData.Set("name", value); } } - public required ApiEnum Status + public required ApiEnum Status { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("status"); + return this._rawData.GetNotNullClass>("status"); } init { this._rawData.Set("status", value); } } @@ -140,7 +138,7 @@ public BillableMetric FromRawUnchecked(IReadOnlyDictionary BillableMetric.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Metrics.StatusConverter))] +[JsonConverter(typeof(StatusConverter))] public enum Status { Active, @@ -148,9 +146,9 @@ public enum Status Archived, } -sealed class StatusConverter : JsonConverter +sealed class StatusConverter : JsonConverter { - public override global::Orb.Models.Metrics.Status Read( + public override Status Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -158,26 +156,22 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "active" => global::Orb.Models.Metrics.Status.Active, - "draft" => global::Orb.Models.Metrics.Status.Draft, - "archived" => global::Orb.Models.Metrics.Status.Archived, - _ => (global::Orb.Models.Metrics.Status)(-1), + "active" => Status.Active, + "draft" => Status.Draft, + "archived" => Status.Archived, + _ => (Status)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Metrics.Status value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Metrics.Status.Active => "active", - global::Orb.Models.Metrics.Status.Draft => "draft", - global::Orb.Models.Metrics.Status.Archived => "archived", + Status.Active => "active", + Status.Draft => "draft", + Status.Archived => "archived", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Metrics/MetricCreateParams.cs b/src/Orb/Models/Metrics/MetricCreateParams.cs index 2a7de890..dfab3ac8 100644 --- a/src/Orb/Models/Metrics/MetricCreateParams.cs +++ b/src/Orb/Models/Metrics/MetricCreateParams.cs @@ -13,8 +13,12 @@ namespace Orb.Models.Metrics; /// This endpoint is used to create a [metric](/core-concepts###metric) using a SQL /// string. See [SQL support](/extensibility/advanced-metrics#sql-support) for a description /// of constructing SQL queries with examples. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class MetricCreateParams : ParamsBase +public record class MetricCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -99,11 +103,14 @@ public required string Sql public MetricCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MetricCreateParams(MetricCreateParams metricCreateParams) : base(metricCreateParams) { this._rawBodyData = new(metricCreateParams._rawBodyData); } +#pragma warning restore CS8618 public MetricCreateParams( IReadOnlyDictionary rawHeaderData, @@ -144,6 +151,28 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(MetricCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/metrics") @@ -169,4 +198,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Metrics/MetricFetchParams.cs b/src/Orb/Models/Metrics/MetricFetchParams.cs index 51a02af2..09e5e1eb 100644 --- a/src/Orb/Models/Metrics/MetricFetchParams.cs +++ b/src/Orb/Models/Metrics/MetricFetchParams.cs @@ -11,18 +11,25 @@ namespace Orb.Models.Metrics; /// /// This endpoint is used to list [metrics](/core-concepts#metric). It returns information /// about the metrics including its name, description, and item. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class MetricFetchParams : ParamsBase +public record class MetricFetchParams : ParamsBase { public string? MetricID { get; init; } public MetricFetchParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MetricFetchParams(MetricFetchParams metricFetchParams) : base(metricFetchParams) { this.MetricID = metricFetchParams.MetricID; } +#pragma warning restore CS8618 public MetricFetchParams( IReadOnlyDictionary rawHeaderData, @@ -57,6 +64,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["MetricID"] = this.MetricID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(MetricFetchParams? other) + { + if (other == null) + { + return false; + } + return (this.MetricID?.Equals(other.MetricID) ?? other.MetricID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -75,4 +104,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Metrics/MetricListParams.cs b/src/Orb/Models/Metrics/MetricListParams.cs index 8feb4f9e..73712145 100644 --- a/src/Orb/Models/Metrics/MetricListParams.cs +++ b/src/Orb/Models/Metrics/MetricListParams.cs @@ -12,8 +12,12 @@ namespace Orb.Models.Metrics; /// This endpoint is used to fetch [metric](/core-concepts##metric) details given /// a metric identifier. It returns information about the metrics including its name, /// description, and item. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class MetricListParams : ParamsBase +public record class MetricListParams : ParamsBase { public DateTimeOffset? CreatedAtGt { @@ -92,8 +96,11 @@ public long? Limit public MetricListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MetricListParams(MetricListParams metricListParams) : base(metricListParams) { } +#pragma warning restore CS8618 public MetricListParams( IReadOnlyDictionary rawHeaderData, @@ -128,6 +135,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(MetricListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/metrics") @@ -144,4 +171,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Metrics/MetricUpdateParams.cs b/src/Orb/Models/Metrics/MetricUpdateParams.cs index 65848c97..2aefc20e 100644 --- a/src/Orb/Models/Metrics/MetricUpdateParams.cs +++ b/src/Orb/Models/Metrics/MetricUpdateParams.cs @@ -12,8 +12,12 @@ namespace Orb.Models.Metrics; /// /// This endpoint allows you to update the `metadata` property on a metric. If you /// pass `null` for the metadata value, it will clear any existing metadata for that invoice. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class MetricUpdateParams : ParamsBase +public record class MetricUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -48,6 +52,8 @@ public IReadOnlyDictionary RawBodyData public MetricUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MetricUpdateParams(MetricUpdateParams metricUpdateParams) : base(metricUpdateParams) { @@ -55,6 +61,7 @@ public MetricUpdateParams(MetricUpdateParams metricUpdateParams) this._rawBodyData = new(metricUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public MetricUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -95,6 +102,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["MetricID"] = this.MetricID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(MetricUpdateParams? other) + { + if (other == null) + { + return false; + } + return (this.MetricID?.Equals(other.MetricID) ?? other.MetricID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -122,4 +153,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Plans/ExternalPlanID/ExternalPlanIDFetchParams.cs b/src/Orb/Models/Plans/ExternalPlanID/ExternalPlanIDFetchParams.cs index 379ba1c8..3a0f2d76 100644 --- a/src/Orb/Models/Plans/ExternalPlanID/ExternalPlanIDFetchParams.cs +++ b/src/Orb/Models/Plans/ExternalPlanID/ExternalPlanIDFetchParams.cs @@ -23,18 +23,25 @@ namespace Orb.Models.Plans.ExternalPlanID; /// object. The `model_type` field determines the key for the configuration object /// that is present. A detailed explanation of price types can be found in the [Price /// schema](/core-concepts#plan-and-price). " +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ExternalPlanIDFetchParams : ParamsBase +public record class ExternalPlanIDFetchParams : ParamsBase { public string? ExternalPlanID { get; init; } public ExternalPlanIDFetchParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ExternalPlanIDFetchParams(ExternalPlanIDFetchParams externalPlanIDFetchParams) : base(externalPlanIDFetchParams) { this.ExternalPlanID = externalPlanIDFetchParams.ExternalPlanID; } +#pragma warning restore CS8618 public ExternalPlanIDFetchParams( IReadOnlyDictionary rawHeaderData, @@ -69,6 +76,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ExternalPlanID"] = this.ExternalPlanID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ExternalPlanIDFetchParams? other) + { + if (other == null) + { + return false; + } + return (this.ExternalPlanID?.Equals(other.ExternalPlanID) ?? other.ExternalPlanID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -88,4 +117,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Plans/ExternalPlanID/ExternalPlanIDUpdateParams.cs b/src/Orb/Models/Plans/ExternalPlanID/ExternalPlanIDUpdateParams.cs index f5e03760..82034fc8 100644 --- a/src/Orb/Models/Plans/ExternalPlanID/ExternalPlanIDUpdateParams.cs +++ b/src/Orb/Models/Plans/ExternalPlanID/ExternalPlanIDUpdateParams.cs @@ -14,8 +14,12 @@ namespace Orb.Models.Plans.ExternalPlanID; /// an existing plan. /// /// Other fields on a plan are currently immutable. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ExternalPlanIDUpdateParams : ParamsBase +public record class ExternalPlanIDUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -65,6 +69,8 @@ public string? ExternalPlanID public ExternalPlanIDUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ExternalPlanIDUpdateParams(ExternalPlanIDUpdateParams externalPlanIDUpdateParams) : base(externalPlanIDUpdateParams) { @@ -72,6 +78,7 @@ public ExternalPlanIDUpdateParams(ExternalPlanIDUpdateParams externalPlanIDUpdat this._rawBodyData = new(externalPlanIDUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public ExternalPlanIDUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -112,6 +119,33 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["OtherExternalPlanID"] = this.OtherExternalPlanID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ExternalPlanIDUpdateParams? other) + { + if (other == null) + { + return false; + } + return ( + this.OtherExternalPlanID?.Equals(other.OtherExternalPlanID) + ?? other.OtherExternalPlanID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -140,4 +174,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Plans/Migrations/MigrationCancelParams.cs b/src/Orb/Models/Plans/Migrations/MigrationCancelParams.cs index 3c14d6e9..ead288e4 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationCancelParams.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationCancelParams.cs @@ -10,8 +10,12 @@ namespace Orb.Models.Plans.Migrations; /// /// This endpoint cancels a migration. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class MigrationCancelParams : ParamsBase +public record class MigrationCancelParams : ParamsBase { public required string PlanID { get; init; } @@ -19,12 +23,15 @@ public sealed record class MigrationCancelParams : ParamsBase public MigrationCancelParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MigrationCancelParams(MigrationCancelParams migrationCancelParams) : base(migrationCancelParams) { this.PlanID = migrationCancelParams.PlanID; this.MigrationID = migrationCancelParams.MigrationID; } +#pragma warning restore CS8618 public MigrationCancelParams( IReadOnlyDictionary rawHeaderData, @@ -59,6 +66,30 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["PlanID"] = this.PlanID, + ["MigrationID"] = this.MigrationID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(MigrationCancelParams? other) + { + if (other == null) + { + return false; + } + return this.PlanID.Equals(other.PlanID) + && (this.MigrationID?.Equals(other.MigrationID) ?? other.MigrationID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -78,4 +109,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Plans/Migrations/MigrationListParams.cs b/src/Orb/Models/Plans/Migrations/MigrationListParams.cs index 9968d05b..e215d2f6 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationListParams.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationListParams.cs @@ -13,8 +13,12 @@ namespace Orb.Models.Plans.Migrations; /// is ordered starting from the most recently created migration. The response also /// includes pagination_metadata, which lets the caller retrieve the next page of /// results if they exist. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class MigrationListParams : ParamsBase +public record class MigrationListParams : ParamsBase { public string? PlanID { get; init; } @@ -55,11 +59,14 @@ public long? Limit public MigrationListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MigrationListParams(MigrationListParams migrationListParams) : base(migrationListParams) { this.PlanID = migrationListParams.PlanID; } +#pragma warning restore CS8618 public MigrationListParams( IReadOnlyDictionary rawHeaderData, @@ -94,6 +101,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["PlanID"] = this.PlanID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(MigrationListParams? other) + { + if (other == null) + { + return false; + } + return (this.PlanID?.Equals(other.PlanID) ?? other.PlanID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -113,4 +142,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Plans/Migrations/MigrationRetrieveParams.cs b/src/Orb/Models/Plans/Migrations/MigrationRetrieveParams.cs index 03ee5e28..f336a58f 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationRetrieveParams.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationRetrieveParams.cs @@ -10,8 +10,12 @@ namespace Orb.Models.Plans.Migrations; /// /// Fetch migration +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class MigrationRetrieveParams : ParamsBase +public record class MigrationRetrieveParams : ParamsBase { public required string PlanID { get; init; } @@ -19,12 +23,15 @@ public sealed record class MigrationRetrieveParams : ParamsBase public MigrationRetrieveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MigrationRetrieveParams(MigrationRetrieveParams migrationRetrieveParams) : base(migrationRetrieveParams) { this.PlanID = migrationRetrieveParams.PlanID; this.MigrationID = migrationRetrieveParams.MigrationID; } +#pragma warning restore CS8618 public MigrationRetrieveParams( IReadOnlyDictionary rawHeaderData, @@ -59,6 +66,30 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["PlanID"] = this.PlanID, + ["MigrationID"] = this.MigrationID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(MigrationRetrieveParams? other) + { + if (other == null) + { + return false; + } + return this.PlanID.Equals(other.PlanID) + && (this.MigrationID?.Equals(other.MigrationID) ?? other.MigrationID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -78,4 +109,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs b/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs index 79e6faa8..10e33b6c 100644 --- a/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs +++ b/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs @@ -44,14 +44,12 @@ public required string PlanID init { this._rawData.Set("plan_id", value); } } - public required ApiEnum Status + public required ApiEnum Status { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("status"); + return this._rawData.GetNotNullClass>("status"); } init { this._rawData.Set("status", value); } } @@ -432,7 +430,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.Plans.Migrations.StatusConverter))] +[JsonConverter(typeof(StatusConverter))] public enum Status { NotStarted, @@ -442,9 +440,9 @@ public enum Status Canceled, } -sealed class StatusConverter : JsonConverter +sealed class StatusConverter : JsonConverter { - public override global::Orb.Models.Plans.Migrations.Status Read( + public override Status Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -452,30 +450,26 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "not_started" => global::Orb.Models.Plans.Migrations.Status.NotStarted, - "in_progress" => global::Orb.Models.Plans.Migrations.Status.InProgress, - "completed" => global::Orb.Models.Plans.Migrations.Status.Completed, - "action_needed" => global::Orb.Models.Plans.Migrations.Status.ActionNeeded, - "canceled" => global::Orb.Models.Plans.Migrations.Status.Canceled, - _ => (global::Orb.Models.Plans.Migrations.Status)(-1), + "not_started" => Status.NotStarted, + "in_progress" => Status.InProgress, + "completed" => Status.Completed, + "action_needed" => Status.ActionNeeded, + "canceled" => Status.Canceled, + _ => (Status)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Plans.Migrations.Status value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Plans.Migrations.Status.NotStarted => "not_started", - global::Orb.Models.Plans.Migrations.Status.InProgress => "in_progress", - global::Orb.Models.Plans.Migrations.Status.Completed => "completed", - global::Orb.Models.Plans.Migrations.Status.ActionNeeded => "action_needed", - global::Orb.Models.Plans.Migrations.Status.Canceled => "canceled", + Status.NotStarted => "not_started", + Status.InProgress => "in_progress", + Status.Completed => "completed", + Status.ActionNeeded => "action_needed", + Status.Canceled => "canceled", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Plans/Plan.cs b/src/Orb/Models/Plans/Plan.cs index b0a7fea4..7f23294a 100644 --- a/src/Orb/Models/Plans/Plan.cs +++ b/src/Orb/Models/Plans/Plan.cs @@ -212,12 +212,12 @@ public required IReadOnlyDictionary Metadata } [System::Obsolete("deprecated")] - public required Models::Minimum? Minimum + public required Minimum? Minimum { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("minimum"); + return this._rawData.GetNullableClass("minimum"); } init { this._rawData.Set("minimum", value); } } @@ -1139,12 +1139,12 @@ public required string? MaximumAmount init { this._rawData.Set("maximum_amount", value); } } - public required Models::Minimum? Minimum + public required Minimum? Minimum { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("minimum"); + return this._rawData.GetNullableClass("minimum"); } init { this._rawData.Set("minimum", value); } } diff --git a/src/Orb/Models/Plans/PlanCreateParams.cs b/src/Orb/Models/Plans/PlanCreateParams.cs index 16b4882a..1f6b3e72 100644 --- a/src/Orb/Models/Plans/PlanCreateParams.cs +++ b/src/Orb/Models/Plans/PlanCreateParams.cs @@ -14,8 +14,12 @@ namespace Orb.Models.Plans; /// /// This endpoint allows creation of plans including their prices. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class PlanCreateParams : ParamsBase +public record class PlanCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -50,18 +54,16 @@ public required string Name /// Prices for this plan. If the plan has phases, this includes prices across /// all phases of the plan. /// - public required IReadOnlyList Prices + public required IReadOnlyList Prices { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNotNullStruct< - ImmutableArray - >("prices"); + return this._rawBodyData.GetNotNullStruct>("prices"); } init { - this._rawBodyData.Set>( + this._rawBodyData.Set>( "prices", ImmutableArray.ToImmutableArray(value) ); @@ -72,18 +74,16 @@ public required string Name /// Adjustments for this plan. If the plan has phases, this includes adjustments /// across all phases of the plan. /// - public IReadOnlyList? Adjustments + public IReadOnlyList? Adjustments { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNullableStruct< - ImmutableArray - >("adjustments"); + return this._rawBodyData.GetNullableStruct>("adjustments"); } init { - this._rawBodyData.Set?>( + this._rawBodyData.Set?>( "adjustments", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -175,14 +175,12 @@ public IReadOnlyList? PlanPhases /// The status of the plan to create (either active or draft). If not specified, /// this defaults to active. /// - public ApiEnum? Status + public ApiEnum? Status { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNullableClass< - ApiEnum - >("status"); + return this._rawBodyData.GetNullableClass>("status"); } init { @@ -197,11 +195,14 @@ public IReadOnlyList? PlanPhases public PlanCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PlanCreateParams(PlanCreateParams planCreateParams) : base(planCreateParams) { this._rawBodyData = new(planCreateParams._rawBodyData); } +#pragma warning restore CS8618 public PlanCreateParams( IReadOnlyDictionary rawHeaderData, @@ -242,6 +243,28 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(PlanCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/plans") @@ -267,9 +290,14 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } -[JsonConverter(typeof(JsonModelConverter))] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Price : JsonModel { /// @@ -321,7 +349,7 @@ public override void Validate() public Price() { } - public Price(global::Orb.Models.Plans.Price price) + public Price(Price price) : base(price) { } public Price(IReadOnlyDictionary rawData) @@ -338,20 +366,17 @@ public Price(IReadOnlyDictionary rawData) #pragma warning restore CS8618 /// - public static global::Orb.Models.Plans.Price FromRawUnchecked( - IReadOnlyDictionary rawData - ) + public static Price FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PriceFromRaw : IFromRawJson +class PriceFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.Price FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.Price.FromRawUnchecked(rawData); + public Price FromRawUnchecked(IReadOnlyDictionary rawData) => + Price.FromRawUnchecked(rawData); } /// @@ -408,7 +433,6 @@ public string ItemID newPlanScalableMatrixWithTieredPricing: (x) => x.ItemID, newPlanCumulativeGroupedBulk: (x) => x.ItemID, cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, newPlanMinimumComposite: (x) => x.ItemID, percent: (x) => x.ItemID, eventOutput: (x) => x.ItemID @@ -449,7 +473,6 @@ public string Name newPlanScalableMatrixWithTieredPricing: (x) => x.Name, newPlanCumulativeGroupedBulk: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, newPlanMinimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name @@ -490,7 +513,6 @@ public string? BillableMetricID newPlanScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, newPlanCumulativeGroupedBulk: (x) => x.BillableMetricID, cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, newPlanMinimumComposite: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID @@ -531,7 +553,6 @@ public bool? BilledInAdvance newPlanScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, newPlanCumulativeGroupedBulk: (x) => x.BilledInAdvance, cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, newPlanMinimumComposite: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance @@ -572,7 +593,6 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newPlanScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, newPlanCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, newPlanMinimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration @@ -613,7 +633,6 @@ public double? ConversionRate newPlanScalableMatrixWithTieredPricing: (x) => x.ConversionRate, newPlanCumulativeGroupedBulk: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, newPlanMinimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate @@ -654,7 +673,6 @@ public string? Currency newPlanScalableMatrixWithTieredPricing: (x) => x.Currency, newPlanCumulativeGroupedBulk: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, newPlanMinimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency @@ -695,7 +713,6 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration newPlanScalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, newPlanCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, newPlanMinimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration @@ -736,7 +753,6 @@ public string? ExternalPriceID newPlanScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, newPlanCumulativeGroupedBulk: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, newPlanMinimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID @@ -777,7 +793,6 @@ public double? FixedPriceQuantity newPlanScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, newPlanCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, newPlanMinimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity @@ -818,7 +833,6 @@ public string? InvoiceGroupingKey newPlanScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, newPlanCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, newPlanMinimumComposite: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey @@ -859,7 +873,6 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration newPlanScalableMatrixWithTieredPricing: (x) => x.InvoicingCycleConfiguration, newPlanCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, newPlanMinimumComposite: (x) => x.InvoicingCycleConfiguration, percent: (x) => x.InvoicingCycleConfiguration, eventOutput: (x) => x.InvoicingCycleConfiguration @@ -900,7 +913,6 @@ public string? ReferenceID newPlanScalableMatrixWithTieredPricing: (x) => x.ReferenceID, newPlanCumulativeGroupedBulk: (x) => x.ReferenceID, cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, newPlanMinimumComposite: (x) => x.ReferenceID, percent: (x) => x.ReferenceID, eventOutput: (x) => x.ReferenceID @@ -926,7 +938,7 @@ public PricePrice(NewPlanBulkPrice value, JsonElement? element = null) this._element = element; } - public PricePrice(global::Orb.Models.Plans.BulkWithFilters value, JsonElement? element = null) + public PricePrice(BulkWithFilters value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -992,10 +1004,7 @@ public PricePrice(NewPlanMatrixWithAllocationPrice value, JsonElement? element = this._element = element; } - public PricePrice( - global::Orb.Models.Plans.TieredWithProration value, - JsonElement? element = null - ) + public PricePrice(TieredWithProration value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1031,10 +1040,7 @@ public PricePrice(NewPlanGroupedWithMeteredMinimumPrice value, JsonElement? elem this._element = element; } - public PricePrice( - global::Orb.Models.Plans.GroupedWithMinMaxThresholds value, - JsonElement? element = null - ) + public PricePrice(GroupedWithMinMaxThresholds value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1079,16 +1085,7 @@ public PricePrice(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element this._element = element; } - public PricePrice( - global::Orb.Models.Plans.CumulativeGroupedAllocation value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public PricePrice(global::Orb.Models.Plans.Minimum value, JsonElement? element = null) + public PricePrice(CumulativeGroupedAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1100,13 +1097,13 @@ public PricePrice(NewPlanMinimumCompositePrice value, JsonElement? element = nul this._element = element; } - public PricePrice(global::Orb.Models.Plans.Percent value, JsonElement? element = null) + public PricePrice(Percent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(global::Orb.Models.Plans.EventOutput value, JsonElement? element = null) + public PricePrice(EventOutput value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -1182,24 +1179,22 @@ public bool TryPickNewPlanBulk([NotNullWhen(true)] out NewPlanBulkPrice? value) /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickBulkWithFilters(out var value)) { - /// // `value` is of type `global::Orb.Models.Plans.BulkWithFilters` + /// // `value` is of type `BulkWithFilters` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickBulkWithFilters( - [NotNullWhen(true)] out global::Orb.Models.Plans.BulkWithFilters? value - ) + public bool TryPickBulkWithFilters([NotNullWhen(true)] out BulkWithFilters? value) { - value = this.Value as global::Orb.Models.Plans.BulkWithFilters; + value = this.Value as BulkWithFilters; return value != null; } @@ -1431,24 +1426,22 @@ public bool TryPickNewPlanMatrixWithAllocation( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickTieredWithProration(out var value)) { - /// // `value` is of type `global::Orb.Models.Plans.TieredWithProration` + /// // `value` is of type `TieredWithProration` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTieredWithProration( - [NotNullWhen(true)] out global::Orb.Models.Plans.TieredWithProration? value - ) + public bool TryPickTieredWithProration([NotNullWhen(true)] out TieredWithProration? value) { - value = this.Value as global::Orb.Models.Plans.TieredWithProration; + value = this.Value as TieredWithProration; return value != null; } @@ -1569,24 +1562,24 @@ public bool TryPickNewPlanGroupedWithMeteredMinimum( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickGroupedWithMinMaxThresholds(out var value)) { - /// // `value` is of type `global::Orb.Models.Plans.GroupedWithMinMaxThresholds` + /// // `value` is of type `GroupedWithMinMaxThresholds` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] out global::Orb.Models.Plans.GroupedWithMinMaxThresholds? value + [NotNullWhen(true)] out GroupedWithMinMaxThresholds? value ) { - value = this.Value as global::Orb.Models.Plans.GroupedWithMinMaxThresholds; + value = this.Value as GroupedWithMinMaxThresholds; return value != null; } @@ -1730,45 +1723,24 @@ public bool TryPickNewPlanCumulativeGroupedBulk( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `global::Orb.Models.Plans.CumulativeGroupedAllocation` + /// // `value` is of type `CumulativeGroupedAllocation` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] out global::Orb.Models.Plans.CumulativeGroupedAllocation? value + [NotNullWhen(true)] out CumulativeGroupedAllocation? value ) { - value = this.Value as global::Orb.Models.Plans.CumulativeGroupedAllocation; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `global::Orb.Models.Plans.Minimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum([NotNullWhen(true)] out global::Orb.Models.Plans.Minimum? value) - { - value = this.Value as global::Orb.Models.Plans.Minimum; + value = this.Value as CumulativeGroupedAllocation; return value != null; } @@ -1797,45 +1769,43 @@ public bool TryPickNewPlanMinimumComposite( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickPercent(out var value)) { - /// // `value` is of type `global::Orb.Models.Plans.Percent` + /// // `value` is of type `Percent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickPercent([NotNullWhen(true)] out global::Orb.Models.Plans.Percent? value) + public bool TryPickPercent([NotNullWhen(true)] out Percent? value) { - value = this.Value as global::Orb.Models.Plans.Percent; + value = this.Value as Percent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickEventOutput(out var value)) { - /// // `value` is of type `global::Orb.Models.Plans.EventOutput` + /// // `value` is of type `EventOutput` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickEventOutput( - [NotNullWhen(true)] out global::Orb.Models.Plans.EventOutput? value - ) + public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) { - value = this.Value as global::Orb.Models.Plans.EventOutput; + value = this.Value as EventOutput; return value != null; } @@ -1856,7 +1826,7 @@ public bool TryPickEventOutput( /// (NewPlanUnitPrice value) => {...}, /// (NewPlanTieredPrice value) => {...}, /// (NewPlanBulkPrice value) => {...}, - /// (global::Orb.Models.Plans.BulkWithFilters value) => {...}, + /// (BulkWithFilters value) => {...}, /// (NewPlanPackagePrice value) => {...}, /// (NewPlanMatrixPrice value) => {...}, /// (NewPlanThresholdTotalAmountPrice value) => {...}, @@ -1867,24 +1837,23 @@ public bool TryPickEventOutput( /// (NewPlanPackageWithAllocationPrice value) => {...}, /// (NewPlanUnitWithPercentPrice value) => {...}, /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Plans.TieredWithProration value) => {...}, + /// (TieredWithProration value) => {...}, /// (NewPlanUnitWithProrationPrice value) => {...}, /// (NewPlanGroupedAllocationPrice value) => {...}, /// (NewPlanBulkWithProrationPrice value) => {...}, /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Plans.GroupedWithMinMaxThresholds value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, /// (NewPlanGroupedTieredPackagePrice value) => {...}, /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, - /// (global::Orb.Models.Plans.CumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Plans.Minimum value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Plans.Percent value) => {...}, - /// (global::Orb.Models.Plans.EventOutput value) => {...} + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -1893,7 +1862,7 @@ public void Switch( System::Action newPlanUnit, System::Action newPlanTiered, System::Action newPlanBulk, - System::Action bulkWithFilters, + System::Action bulkWithFilters, System::Action newPlanPackage, System::Action newPlanMatrix, System::Action newPlanThresholdTotalAmount, @@ -1904,24 +1873,23 @@ public void Switch( System::Action newPlanPackageWithAllocation, System::Action newPlanUnitWithPercent, System::Action newPlanMatrixWithAllocation, - System::Action tieredWithProration, + System::Action tieredWithProration, System::Action newPlanUnitWithProration, System::Action newPlanGroupedAllocation, System::Action newPlanBulkWithProration, System::Action newPlanGroupedWithProratedMinimum, System::Action newPlanGroupedWithMeteredMinimum, - System::Action groupedWithMinMaxThresholds, + System::Action groupedWithMinMaxThresholds, System::Action newPlanMatrixWithDisplayName, System::Action newPlanGroupedTieredPackage, System::Action newPlanMaxGroupTieredPackage, System::Action newPlanScalableMatrixWithUnitPricing, System::Action newPlanScalableMatrixWithTieredPricing, System::Action newPlanCumulativeGroupedBulk, - System::Action cumulativeGroupedAllocation, - System::Action minimum, + System::Action cumulativeGroupedAllocation, System::Action newPlanMinimumComposite, - System::Action percent, - System::Action eventOutput + System::Action percent, + System::Action eventOutput ) { switch (this.Value) @@ -1935,7 +1903,7 @@ public void Switch( case NewPlanBulkPrice value: newPlanBulk(value); break; - case global::Orb.Models.Plans.BulkWithFilters value: + case BulkWithFilters value: bulkWithFilters(value); break; case NewPlanPackagePrice value: @@ -1968,7 +1936,7 @@ public void Switch( case NewPlanMatrixWithAllocationPrice value: newPlanMatrixWithAllocation(value); break; - case global::Orb.Models.Plans.TieredWithProration value: + case TieredWithProration value: tieredWithProration(value); break; case NewPlanUnitWithProrationPrice value: @@ -1986,7 +1954,7 @@ public void Switch( case NewPlanGroupedWithMeteredMinimumPrice value: newPlanGroupedWithMeteredMinimum(value); break; - case global::Orb.Models.Plans.GroupedWithMinMaxThresholds value: + case GroupedWithMinMaxThresholds value: groupedWithMinMaxThresholds(value); break; case NewPlanMatrixWithDisplayNamePrice value: @@ -2007,19 +1975,16 @@ public void Switch( case NewPlanCumulativeGroupedBulkPrice value: newPlanCumulativeGroupedBulk(value); break; - case global::Orb.Models.Plans.CumulativeGroupedAllocation value: + case CumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case global::Orb.Models.Plans.Minimum value: - minimum(value); - break; case NewPlanMinimumCompositePrice value: newPlanMinimumComposite(value); break; - case global::Orb.Models.Plans.Percent value: + case Percent value: percent(value); break; - case global::Orb.Models.Plans.EventOutput value: + case EventOutput value: eventOutput(value); break; default: @@ -2045,7 +2010,7 @@ public void Switch( /// (NewPlanUnitPrice value) => {...}, /// (NewPlanTieredPrice value) => {...}, /// (NewPlanBulkPrice value) => {...}, - /// (global::Orb.Models.Plans.BulkWithFilters value) => {...}, + /// (BulkWithFilters value) => {...}, /// (NewPlanPackagePrice value) => {...}, /// (NewPlanMatrixPrice value) => {...}, /// (NewPlanThresholdTotalAmountPrice value) => {...}, @@ -2056,24 +2021,23 @@ public void Switch( /// (NewPlanPackageWithAllocationPrice value) => {...}, /// (NewPlanUnitWithPercentPrice value) => {...}, /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Plans.TieredWithProration value) => {...}, + /// (TieredWithProration value) => {...}, /// (NewPlanUnitWithProrationPrice value) => {...}, /// (NewPlanGroupedAllocationPrice value) => {...}, /// (NewPlanBulkWithProrationPrice value) => {...}, /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Plans.GroupedWithMinMaxThresholds value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, /// (NewPlanGroupedTieredPackagePrice value) => {...}, /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, - /// (global::Orb.Models.Plans.CumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Plans.Minimum value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Plans.Percent value) => {...}, - /// (global::Orb.Models.Plans.EventOutput value) => {...} + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -2082,7 +2046,7 @@ public T Match( System::Func newPlanUnit, System::Func newPlanTiered, System::Func newPlanBulk, - System::Func bulkWithFilters, + System::Func bulkWithFilters, System::Func newPlanPackage, System::Func newPlanMatrix, System::Func newPlanThresholdTotalAmount, @@ -2093,16 +2057,13 @@ public T Match( System::Func newPlanPackageWithAllocation, System::Func newPlanUnitWithPercent, System::Func newPlanMatrixWithAllocation, - System::Func tieredWithProration, + System::Func tieredWithProration, System::Func newPlanUnitWithProration, System::Func newPlanGroupedAllocation, System::Func newPlanBulkWithProration, System::Func newPlanGroupedWithProratedMinimum, System::Func newPlanGroupedWithMeteredMinimum, - System::Func< - global::Orb.Models.Plans.GroupedWithMinMaxThresholds, - T - > groupedWithMinMaxThresholds, + System::Func groupedWithMinMaxThresholds, System::Func newPlanMatrixWithDisplayName, System::Func newPlanGroupedTieredPackage, System::Func newPlanMaxGroupTieredPackage, @@ -2115,14 +2076,10 @@ public T Match( T > newPlanScalableMatrixWithTieredPricing, System::Func newPlanCumulativeGroupedBulk, - System::Func< - global::Orb.Models.Plans.CumulativeGroupedAllocation, - T - > cumulativeGroupedAllocation, - System::Func minimum, + System::Func cumulativeGroupedAllocation, System::Func newPlanMinimumComposite, - System::Func percent, - System::Func eventOutput + System::Func percent, + System::Func eventOutput ) { return this.Value switch @@ -2130,7 +2087,7 @@ public T Match( NewPlanUnitPrice value => newPlanUnit(value), NewPlanTieredPrice value => newPlanTiered(value), NewPlanBulkPrice value => newPlanBulk(value), - global::Orb.Models.Plans.BulkWithFilters value => bulkWithFilters(value), + BulkWithFilters value => bulkWithFilters(value), NewPlanPackagePrice value => newPlanPackage(value), NewPlanMatrixPrice value => newPlanMatrix(value), NewPlanThresholdTotalAmountPrice value => newPlanThresholdTotalAmount(value), @@ -2141,7 +2098,7 @@ public T Match( NewPlanPackageWithAllocationPrice value => newPlanPackageWithAllocation(value), NewPlanUnitWithPercentPrice value => newPlanUnitWithPercent(value), NewPlanMatrixWithAllocationPrice value => newPlanMatrixWithAllocation(value), - global::Orb.Models.Plans.TieredWithProration value => tieredWithProration(value), + TieredWithProration value => tieredWithProration(value), NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), @@ -2149,8 +2106,7 @@ public T Match( value ), NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), - global::Orb.Models.Plans.GroupedWithMinMaxThresholds value => - groupedWithMinMaxThresholds(value), + GroupedWithMinMaxThresholds value => groupedWithMinMaxThresholds(value), NewPlanMatrixWithDisplayNamePrice value => newPlanMatrixWithDisplayName(value), NewPlanGroupedTieredPackagePrice value => newPlanGroupedTieredPackage(value), NewPlanMaxGroupTieredPackagePrice value => newPlanMaxGroupTieredPackage(value), @@ -2160,12 +2116,10 @@ public T Match( NewPlanScalableMatrixWithTieredPricingPrice value => newPlanScalableMatrixWithTieredPricing(value), NewPlanCumulativeGroupedBulkPrice value => newPlanCumulativeGroupedBulk(value), - global::Orb.Models.Plans.CumulativeGroupedAllocation value => - cumulativeGroupedAllocation(value), - global::Orb.Models.Plans.Minimum value => minimum(value), + CumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), - global::Orb.Models.Plans.Percent value => percent(value), - global::Orb.Models.Plans.EventOutput value => eventOutput(value), + Percent value => percent(value), + EventOutput value => eventOutput(value), _ => throw new OrbInvalidDataException("Data did not match any variant of PricePrice"), }; } @@ -2176,8 +2130,7 @@ public T Match( public static implicit operator PricePrice(NewPlanBulkPrice value) => new(value); - public static implicit operator PricePrice(global::Orb.Models.Plans.BulkWithFilters value) => - new(value); + public static implicit operator PricePrice(BulkWithFilters value) => new(value); public static implicit operator PricePrice(NewPlanPackagePrice value) => new(value); @@ -2203,9 +2156,7 @@ public static implicit operator PricePrice(NewPlanPackageWithAllocationPrice val public static implicit operator PricePrice(NewPlanMatrixWithAllocationPrice value) => new(value); - public static implicit operator PricePrice( - global::Orb.Models.Plans.TieredWithProration value - ) => new(value); + public static implicit operator PricePrice(TieredWithProration value) => new(value); public static implicit operator PricePrice(NewPlanUnitWithProrationPrice value) => new(value); @@ -2219,9 +2170,7 @@ public static implicit operator PricePrice(NewPlanGroupedWithProratedMinimumPric public static implicit operator PricePrice(NewPlanGroupedWithMeteredMinimumPrice value) => new(value); - public static implicit operator PricePrice( - global::Orb.Models.Plans.GroupedWithMinMaxThresholds value - ) => new(value); + public static implicit operator PricePrice(GroupedWithMinMaxThresholds value) => new(value); public static implicit operator PricePrice(NewPlanMatrixWithDisplayNamePrice value) => new(value); @@ -2241,20 +2190,13 @@ public static implicit operator PricePrice(NewPlanScalableMatrixWithTieredPricin public static implicit operator PricePrice(NewPlanCumulativeGroupedBulkPrice value) => new(value); - public static implicit operator PricePrice( - global::Orb.Models.Plans.CumulativeGroupedAllocation value - ) => new(value); - - public static implicit operator PricePrice(global::Orb.Models.Plans.Minimum value) => - new(value); + public static implicit operator PricePrice(CumulativeGroupedAllocation value) => new(value); public static implicit operator PricePrice(NewPlanMinimumCompositePrice value) => new(value); - public static implicit operator PricePrice(global::Orb.Models.Plans.Percent value) => - new(value); + public static implicit operator PricePrice(Percent value) => new(value); - public static implicit operator PricePrice(global::Orb.Models.Plans.EventOutput value) => - new(value); + public static implicit operator PricePrice(EventOutput value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2303,7 +2245,6 @@ public override void Validate() newPlanScalableMatrixWithTieredPricing.Validate(), (newPlanCumulativeGroupedBulk) => newPlanCumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), (newPlanMinimumComposite) => newPlanMinimumComposite.Validate(), (percent) => percent.Validate(), (eventOutput) => eventOutput.Validate() @@ -2415,11 +2356,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2660,11 +2600,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2795,11 +2734,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2955,30 +2893,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3022,10 +2937,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3044,11 +2956,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3080,25 +2988,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.BulkWithFilters, - global::Orb.Models.Plans.BulkWithFiltersFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class BulkWithFilters : JsonModel { /// /// Configuration for bulk_with_filters pricing /// - public required global::Orb.Models.Plans.BulkWithFiltersConfig BulkWithFiltersConfig + public required BulkWithFiltersConfig BulkWithFiltersConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "bulk_with_filters_config" - ); + return this._rawData.GetNotNullClass("bulk_with_filters_config"); } init { this._rawData.Set("bulk_with_filters_config", value); } } @@ -3106,14 +3007,12 @@ public sealed record class BulkWithFilters : JsonModel /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( - "cadence" - ); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } @@ -3216,14 +3115,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Plans.ConversionRateConfig? ConversionRateConfig + public ConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); + return this._rawData.GetNullableClass("conversion_rate_config"); } init { this._rawData.Set("conversion_rate_config", value); } } @@ -3383,7 +3280,7 @@ public BulkWithFilters() this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } - public BulkWithFilters(global::Orb.Models.Plans.BulkWithFilters bulkWithFilters) + public BulkWithFilters(BulkWithFilters bulkWithFilters) : base(bulkWithFilters) { } public BulkWithFilters(IReadOnlyDictionary rawData) @@ -3401,49 +3298,39 @@ public BulkWithFilters(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.BulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class BulkWithFiltersFromRaw : IFromRawJson +class BulkWithFiltersFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.BulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.BulkWithFilters.FromRawUnchecked(rawData); + public BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) => + BulkWithFilters.FromRawUnchecked(rawData); } /// /// Configuration for bulk_with_filters pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.BulkWithFiltersConfig, - global::Orb.Models.Plans.BulkWithFiltersConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class BulkWithFiltersConfig : JsonModel { /// /// Property filters to apply (all must match) /// - public required IReadOnlyList Filters + public required IReadOnlyList Filters { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct>( - "filters" - ); + return this._rawData.GetNotNullStruct>("filters"); } init { - this._rawData.Set>( + this._rawData.Set>( "filters", ImmutableArray.ToImmutableArray(value) ); @@ -3453,18 +3340,16 @@ public sealed record class BulkWithFiltersConfig : JsonModel /// /// Bulk tiers for rating based on total usage volume /// - public required IReadOnlyList Tiers + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct>( - "tiers" - ); + return this._rawData.GetNotNullStruct>("tiers"); } init { - this._rawData.Set>( + this._rawData.Set>( "tiers", ImmutableArray.ToImmutableArray(value) ); @@ -3486,9 +3371,7 @@ public override void Validate() public BulkWithFiltersConfig() { } - public BulkWithFiltersConfig( - global::Orb.Models.Plans.BulkWithFiltersConfig bulkWithFiltersConfig - ) + public BulkWithFiltersConfig(BulkWithFiltersConfig bulkWithFiltersConfig) : base(bulkWithFiltersConfig) { } public BulkWithFiltersConfig(IReadOnlyDictionary rawData) @@ -3504,8 +3387,8 @@ public BulkWithFiltersConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.BulkWithFiltersConfig FromRawUnchecked( + /// + public static BulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -3513,23 +3396,18 @@ IReadOnlyDictionary rawData } } -class BulkWithFiltersConfigFromRaw : IFromRawJson +class BulkWithFiltersConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.BulkWithFiltersConfig FromRawUnchecked( + public BulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.BulkWithFiltersConfig.FromRawUnchecked(rawData); + ) => BulkWithFiltersConfig.FromRawUnchecked(rawData); } /// /// Configuration for a single property filter /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.Filter, - global::Orb.Models.Plans.FilterFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Filter : JsonModel { /// @@ -3567,7 +3445,7 @@ public override void Validate() public Filter() { } - public Filter(global::Orb.Models.Plans.Filter filter) + public Filter(Filter filter) : base(filter) { } public Filter(IReadOnlyDictionary rawData) @@ -3583,29 +3461,24 @@ public Filter(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Filter FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class FilterFromRaw : IFromRawJson +class FilterFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.Filter.FromRawUnchecked(rawData); + public Filter FromRawUnchecked(IReadOnlyDictionary rawData) => + Filter.FromRawUnchecked(rawData); } /// /// Configuration for a single bulk pricing tier /// -[JsonConverter( - typeof(JsonModelConverter) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Tier : JsonModel { /// @@ -3643,7 +3516,7 @@ public override void Validate() public Tier() { } - public Tier(global::Orb.Models.Plans.Tier tier) + public Tier(Tier tier) : base(tier) { } public Tier(IReadOnlyDictionary rawData) @@ -3659,10 +3532,8 @@ public Tier(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Tier FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } @@ -3675,18 +3546,17 @@ public Tier(string unitAmount) } } -class TierFromRaw : IFromRawJson +class TierFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.Tier.FromRawUnchecked(rawData); + public Tier FromRawUnchecked(IReadOnlyDictionary rawData) => + Tier.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Plans.CadenceConverter))] +[JsonConverter(typeof(CadenceConverter))] public enum Cadence { Annual, @@ -3697,9 +3567,9 @@ public enum Cadence Custom, } -sealed class CadenceConverter : JsonConverter +sealed class CadenceConverter : JsonConverter { - public override global::Orb.Models.Plans.Cadence Read( + public override Cadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -3707,32 +3577,28 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Plans.Cadence.Annual, - "semi_annual" => global::Orb.Models.Plans.Cadence.SemiAnnual, - "monthly" => global::Orb.Models.Plans.Cadence.Monthly, - "quarterly" => global::Orb.Models.Plans.Cadence.Quarterly, - "one_time" => global::Orb.Models.Plans.Cadence.OneTime, - "custom" => global::Orb.Models.Plans.Cadence.Custom, - _ => (global::Orb.Models.Plans.Cadence)(-1), + "annual" => Cadence.Annual, + "semi_annual" => Cadence.SemiAnnual, + "monthly" => Cadence.Monthly, + "quarterly" => Cadence.Quarterly, + "one_time" => Cadence.OneTime, + "custom" => Cadence.Custom, + _ => (Cadence)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Plans.Cadence value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Cadence value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Plans.Cadence.Annual => "annual", - global::Orb.Models.Plans.Cadence.SemiAnnual => "semi_annual", - global::Orb.Models.Plans.Cadence.Monthly => "monthly", - global::Orb.Models.Plans.Cadence.Quarterly => "quarterly", - global::Orb.Models.Plans.Cadence.OneTime => "one_time", - global::Orb.Models.Plans.Cadence.Custom => "custom", + Cadence.Annual => "annual", + Cadence.SemiAnnual => "semi_annual", + Cadence.Monthly => "monthly", + Cadence.Quarterly => "quarterly", + Cadence.OneTime => "one_time", + Cadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -3742,7 +3608,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.Plans.ConversionRateConfigConverter))] +[JsonConverter(typeof(ConversionRateConfigConverter))] public record class ConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -3895,13 +3761,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Plans.ConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); + public static implicit operator ConversionRateConfig(SharedUnitConversionRateConfig value) => + new(value); - public static implicit operator global::Orb.Models.Plans.ConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); + public static implicit operator ConversionRateConfig(SharedTieredConversionRateConfig value) => + new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -3924,7 +3788,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Plans.ConversionRateConfig? other) + public virtual bool Equals(ConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -3938,10 +3802,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class ConversionRateConfigConverter - : JsonConverter +sealed class ConversionRateConfigConverter : JsonConverter { - public override global::Orb.Models.Plans.ConversionRateConfig? Read( + public override ConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4006,14 +3869,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Plans.ConversionRateConfig(element); + return new ConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.ConversionRateConfig value, + ConversionRateConfig value, JsonSerializerOptions options ) { @@ -4021,25 +3884,20 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.TieredWithProration, - global::Orb.Models.Plans.TieredWithProrationFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class TieredWithProration : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } init { this._rawData.Set("cadence", value); } } @@ -4086,12 +3944,12 @@ public required string Name /// /// Configuration for tiered_with_proration pricing /// - public required global::Orb.Models.Plans.TieredWithProrationConfig TieredWithProrationConfig + public required TieredWithProrationConfig TieredWithProrationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "tiered_with_proration_config" ); } @@ -4157,12 +4015,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Plans.TieredWithProrationConversionRateConfig? ConversionRateConfig + public TieredWithProrationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -4324,7 +4182,7 @@ public TieredWithProration() this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } - public TieredWithProration(global::Orb.Models.Plans.TieredWithProration tieredWithProration) + public TieredWithProration(TieredWithProration tieredWithProration) : base(tieredWithProration) { } public TieredWithProration(IReadOnlyDictionary rawData) @@ -4342,8 +4200,8 @@ public TieredWithProration(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.TieredWithProration FromRawUnchecked( + /// + public static TieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4351,18 +4209,17 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationFromRaw : IFromRawJson +class TieredWithProrationFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.TieredWithProration FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.TieredWithProration.FromRawUnchecked(rawData); + public TieredWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredWithProration.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Plans.TieredWithProrationCadenceConverter))] +[JsonConverter(typeof(TieredWithProrationCadenceConverter))] public enum TieredWithProrationCadence { Annual, @@ -4373,10 +4230,9 @@ public enum TieredWithProrationCadence Custom, } -sealed class TieredWithProrationCadenceConverter - : JsonConverter +sealed class TieredWithProrationCadenceConverter : JsonConverter { - public override global::Orb.Models.Plans.TieredWithProrationCadence Read( + public override TieredWithProrationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4384,19 +4240,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Plans.TieredWithProrationCadence.Annual, - "semi_annual" => global::Orb.Models.Plans.TieredWithProrationCadence.SemiAnnual, - "monthly" => global::Orb.Models.Plans.TieredWithProrationCadence.Monthly, - "quarterly" => global::Orb.Models.Plans.TieredWithProrationCadence.Quarterly, - "one_time" => global::Orb.Models.Plans.TieredWithProrationCadence.OneTime, - "custom" => global::Orb.Models.Plans.TieredWithProrationCadence.Custom, - _ => (global::Orb.Models.Plans.TieredWithProrationCadence)(-1), + "annual" => TieredWithProrationCadence.Annual, + "semi_annual" => TieredWithProrationCadence.SemiAnnual, + "monthly" => TieredWithProrationCadence.Monthly, + "quarterly" => TieredWithProrationCadence.Quarterly, + "one_time" => TieredWithProrationCadence.OneTime, + "custom" => TieredWithProrationCadence.Custom, + _ => (TieredWithProrationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.TieredWithProrationCadence value, + TieredWithProrationCadence value, JsonSerializerOptions options ) { @@ -4404,12 +4260,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Plans.TieredWithProrationCadence.Annual => "annual", - global::Orb.Models.Plans.TieredWithProrationCadence.SemiAnnual => "semi_annual", - global::Orb.Models.Plans.TieredWithProrationCadence.Monthly => "monthly", - global::Orb.Models.Plans.TieredWithProrationCadence.Quarterly => "quarterly", - global::Orb.Models.Plans.TieredWithProrationCadence.OneTime => "one_time", - global::Orb.Models.Plans.TieredWithProrationCadence.Custom => "custom", + TieredWithProrationCadence.Annual => "annual", + TieredWithProrationCadence.SemiAnnual => "semi_annual", + TieredWithProrationCadence.Monthly => "monthly", + TieredWithProrationCadence.Quarterly => "quarterly", + TieredWithProrationCadence.OneTime => "one_time", + TieredWithProrationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -4423,10 +4279,7 @@ JsonSerializerOptions options /// Configuration for tiered_with_proration pricing /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.TieredWithProrationConfig, - global::Orb.Models.Plans.TieredWithProrationConfigFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class TieredWithProrationConfig : JsonModel { @@ -4434,20 +4287,21 @@ public sealed record class TieredWithProrationConfig : JsonModel /// Tiers for rating based on total usage quantities into the specified tier /// with proration /// - public required IReadOnlyList Tiers + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + return this._rawData.GetNotNullStruct>( + "tiers" + ); } init { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); } } @@ -4462,9 +4316,7 @@ public override void Validate() public TieredWithProrationConfig() { } - public TieredWithProrationConfig( - global::Orb.Models.Plans.TieredWithProrationConfig tieredWithProrationConfig - ) + public TieredWithProrationConfig(TieredWithProrationConfig tieredWithProrationConfig) : base(tieredWithProrationConfig) { } public TieredWithProrationConfig(IReadOnlyDictionary rawData) @@ -4480,8 +4332,8 @@ public TieredWithProrationConfig(IReadOnlyDictionary rawDat } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.TieredWithProrationConfig FromRawUnchecked( + /// + public static TieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4489,32 +4341,26 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public TieredWithProrationConfig( - IReadOnlyList tiers - ) + public TieredWithProrationConfig(IReadOnlyList tiers) : this() { this.Tiers = tiers; } } -class TieredWithProrationConfigFromRaw - : IFromRawJson +class TieredWithProrationConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.TieredWithProrationConfig FromRawUnchecked( + public TieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.TieredWithProrationConfig.FromRawUnchecked(rawData); + ) => TieredWithProrationConfig.FromRawUnchecked(rawData); } /// /// Configuration for a single tiered with proration tier /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.TieredWithProrationConfigTier, - global::Orb.Models.Plans.TieredWithProrationConfigTierFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class TieredWithProrationConfigTier : JsonModel { @@ -4554,7 +4400,7 @@ public override void Validate() public TieredWithProrationConfigTier() { } public TieredWithProrationConfigTier( - global::Orb.Models.Plans.TieredWithProrationConfigTier tieredWithProrationConfigTier + TieredWithProrationConfigTier tieredWithProrationConfigTier ) : base(tieredWithProrationConfigTier) { } @@ -4571,8 +4417,8 @@ public TieredWithProrationConfigTier(IReadOnlyDictionary ra } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.TieredWithProrationConfigTier FromRawUnchecked( + /// + public static TieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4580,16 +4426,15 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationConfigTierFromRaw - : IFromRawJson +class TieredWithProrationConfigTierFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.TieredWithProrationConfigTier FromRawUnchecked( + public TieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.TieredWithProrationConfigTier.FromRawUnchecked(rawData); + ) => TieredWithProrationConfigTier.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Plans.TieredWithProrationConversionRateConfigConverter))] +[JsonConverter(typeof(TieredWithProrationConversionRateConfigConverter))] public record class TieredWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -4748,11 +4593,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Plans.TieredWithProrationConversionRateConfig( + public static implicit operator TieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Plans.TieredWithProrationConversionRateConfig( + public static implicit operator TieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -4777,9 +4622,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Plans.TieredWithProrationConversionRateConfig? other - ) + public virtual bool Equals(TieredWithProrationConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -4794,9 +4637,9 @@ public override string ToString() => } sealed class TieredWithProrationConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Plans.TieredWithProrationConversionRateConfig? Read( + public override TieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4861,16 +4704,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Plans.TieredWithProrationConversionRateConfig( - element - ); + return new TieredWithProrationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.TieredWithProrationConversionRateConfig value, + TieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -4879,26 +4720,20 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.GroupedWithMinMaxThresholds, - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class GroupedWithMinMaxThresholds : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -4907,12 +4742,12 @@ public required ApiEnum< /// /// Configuration for grouped_with_min_max_thresholds pricing /// - public required global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + public required GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "grouped_with_min_max_thresholds_config" ); } @@ -5017,12 +4852,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + public GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5184,9 +5019,7 @@ public GroupedWithMinMaxThresholds() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } - public GroupedWithMinMaxThresholds( - global::Orb.Models.Plans.GroupedWithMinMaxThresholds groupedWithMinMaxThresholds - ) + public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) : base(groupedWithMinMaxThresholds) { } public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) @@ -5204,8 +5037,8 @@ public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawD } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.GroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5213,19 +5046,18 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class GroupedWithMinMaxThresholdsFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.GroupedWithMinMaxThresholds FromRawUnchecked( + public GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + ) => GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Plans.GroupedWithMinMaxThresholdsCadenceConverter))] +[JsonConverter(typeof(GroupedWithMinMaxThresholdsCadenceConverter))] public enum GroupedWithMinMaxThresholdsCadence { Annual, @@ -5237,9 +5069,9 @@ public enum GroupedWithMinMaxThresholdsCadence } sealed class GroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Plans.GroupedWithMinMaxThresholdsCadence Read( + public override GroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5247,19 +5079,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Plans.GroupedWithMinMaxThresholdsCadence.Annual, - "semi_annual" => global::Orb.Models.Plans.GroupedWithMinMaxThresholdsCadence.SemiAnnual, - "monthly" => global::Orb.Models.Plans.GroupedWithMinMaxThresholdsCadence.Monthly, - "quarterly" => global::Orb.Models.Plans.GroupedWithMinMaxThresholdsCadence.Quarterly, - "one_time" => global::Orb.Models.Plans.GroupedWithMinMaxThresholdsCadence.OneTime, - "custom" => global::Orb.Models.Plans.GroupedWithMinMaxThresholdsCadence.Custom, - _ => (global::Orb.Models.Plans.GroupedWithMinMaxThresholdsCadence)(-1), + "annual" => GroupedWithMinMaxThresholdsCadence.Annual, + "semi_annual" => GroupedWithMinMaxThresholdsCadence.SemiAnnual, + "monthly" => GroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => GroupedWithMinMaxThresholdsCadence.Quarterly, + "one_time" => GroupedWithMinMaxThresholdsCadence.OneTime, + "custom" => GroupedWithMinMaxThresholdsCadence.Custom, + _ => (GroupedWithMinMaxThresholdsCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsCadence value, + GroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -5267,14 +5099,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsCadence.Annual => "annual", - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsCadence.SemiAnnual => - "semi_annual", - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsCadence.Monthly => "monthly", - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsCadence.Quarterly => - "quarterly", - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsCadence.OneTime => "one_time", - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsCadence.Custom => "custom", + GroupedWithMinMaxThresholdsCadence.Annual => "annual", + GroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", + GroupedWithMinMaxThresholdsCadence.Monthly => "monthly", + GroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", + GroupedWithMinMaxThresholdsCadence.OneTime => "one_time", + GroupedWithMinMaxThresholdsCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -5289,8 +5119,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConfig, - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConfigFromRaw + GroupedWithMinMaxThresholdsConfig, + GroupedWithMinMaxThresholdsConfigFromRaw >) )] public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel @@ -5359,7 +5189,7 @@ public override void Validate() public GroupedWithMinMaxThresholdsConfig() { } public GroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig + GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) : base(groupedWithMinMaxThresholdsConfig) { } @@ -5376,8 +5206,8 @@ public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary - public static global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5385,18 +5215,15 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class GroupedWithMinMaxThresholdsConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); + ) => GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConversionRateConfigConverter) -)] +[JsonConverter(typeof(GroupedWithMinMaxThresholdsConversionRateConfigConverter))] public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5555,11 +5382,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -5584,9 +5411,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConversionRateConfig? other - ) + public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -5601,9 +5426,9 @@ public override string ToString() => } sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override GroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5668,16 +5493,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConversionRateConfig( - element - ); + return new GroupedWithMinMaxThresholdsConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConversionRateConfig value, + GroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -5686,26 +5509,20 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.CumulativeGroupedAllocation, - global::Orb.Models.Plans.CumulativeGroupedAllocationFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class CumulativeGroupedAllocation : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Plans.CumulativeGroupedAllocationCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -5714,12 +5531,12 @@ public required ApiEnum< /// /// Configuration for cumulative_grouped_allocation pricing /// - public required global::Orb.Models.Plans.CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "cumulative_grouped_allocation_config" ); } @@ -5824,12 +5641,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Plans.CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + public CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5991,9 +5808,7 @@ public CumulativeGroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public CumulativeGroupedAllocation( - global::Orb.Models.Plans.CumulativeGroupedAllocation cumulativeGroupedAllocation - ) + public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) : base(cumulativeGroupedAllocation) { } public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) @@ -6011,8 +5826,8 @@ public CumulativeGroupedAllocation(IReadOnlyDictionary rawD } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.CumulativeGroupedAllocation FromRawUnchecked( + /// + public static CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6020,19 +5835,18 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationFromRaw - : IFromRawJson +class CumulativeGroupedAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.CumulativeGroupedAllocation FromRawUnchecked( + public CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.CumulativeGroupedAllocation.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Plans.CumulativeGroupedAllocationCadenceConverter))] +[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] public enum CumulativeGroupedAllocationCadence { Annual, @@ -6044,9 +5858,9 @@ public enum CumulativeGroupedAllocationCadence } sealed class CumulativeGroupedAllocationCadenceConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Plans.CumulativeGroupedAllocationCadence Read( + public override CumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6054,19 +5868,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Plans.CumulativeGroupedAllocationCadence.Annual, - "semi_annual" => global::Orb.Models.Plans.CumulativeGroupedAllocationCadence.SemiAnnual, - "monthly" => global::Orb.Models.Plans.CumulativeGroupedAllocationCadence.Monthly, - "quarterly" => global::Orb.Models.Plans.CumulativeGroupedAllocationCadence.Quarterly, - "one_time" => global::Orb.Models.Plans.CumulativeGroupedAllocationCadence.OneTime, - "custom" => global::Orb.Models.Plans.CumulativeGroupedAllocationCadence.Custom, - _ => (global::Orb.Models.Plans.CumulativeGroupedAllocationCadence)(-1), + "annual" => CumulativeGroupedAllocationCadence.Annual, + "semi_annual" => CumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => CumulativeGroupedAllocationCadence.Monthly, + "quarterly" => CumulativeGroupedAllocationCadence.Quarterly, + "one_time" => CumulativeGroupedAllocationCadence.OneTime, + "custom" => CumulativeGroupedAllocationCadence.Custom, + _ => (CumulativeGroupedAllocationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.CumulativeGroupedAllocationCadence value, + CumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -6074,14 +5888,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Plans.CumulativeGroupedAllocationCadence.Annual => "annual", - global::Orb.Models.Plans.CumulativeGroupedAllocationCadence.SemiAnnual => - "semi_annual", - global::Orb.Models.Plans.CumulativeGroupedAllocationCadence.Monthly => "monthly", - global::Orb.Models.Plans.CumulativeGroupedAllocationCadence.Quarterly => - "quarterly", - global::Orb.Models.Plans.CumulativeGroupedAllocationCadence.OneTime => "one_time", - global::Orb.Models.Plans.CumulativeGroupedAllocationCadence.Custom => "custom", + CumulativeGroupedAllocationCadence.Annual => "annual", + CumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", + CumulativeGroupedAllocationCadence.Monthly => "monthly", + CumulativeGroupedAllocationCadence.Quarterly => "quarterly", + CumulativeGroupedAllocationCadence.OneTime => "one_time", + CumulativeGroupedAllocationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -6096,8 +5908,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Plans.CumulativeGroupedAllocationConfig, - global::Orb.Models.Plans.CumulativeGroupedAllocationConfigFromRaw + CumulativeGroupedAllocationConfig, + CumulativeGroupedAllocationConfigFromRaw >) )] public sealed record class CumulativeGroupedAllocationConfig : JsonModel @@ -6166,7 +5978,7 @@ public override void Validate() public CumulativeGroupedAllocationConfig() { } public CumulativeGroupedAllocationConfig( - global::Orb.Models.Plans.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig ) : base(cumulativeGroupedAllocationConfig) { } @@ -6183,8 +5995,8 @@ public CumulativeGroupedAllocationConfig(IReadOnlyDictionary - public static global::Orb.Models.Plans.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6192,18 +6004,15 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class CumulativeGroupedAllocationConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.CumulativeGroupedAllocationConfig FromRawUnchecked( + public CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Plans.CumulativeGroupedAllocationConversionRateConfigConverter) -)] +[JsonConverter(typeof(CumulativeGroupedAllocationConversionRateConfigConverter))] public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6362,11 +6171,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Plans.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Plans.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6391,9 +6200,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Plans.CumulativeGroupedAllocationConversionRateConfig? other - ) + public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -6408,9 +6215,9 @@ public override string ToString() => } sealed class CumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Plans.CumulativeGroupedAllocationConversionRateConfig? Read( + public override CumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6475,16 +6282,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Plans.CumulativeGroupedAllocationConversionRateConfig( - element - ); + return new CumulativeGroupedAllocationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.CumulativeGroupedAllocationConversionRateConfig value, + CumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -6492,23 +6297,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.Minimum, - global::Orb.Models.Plans.MinimumFromRaw - >) -)] -public sealed record class Minimum : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Percent : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>("cadence"); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } @@ -6527,44 +6327,42 @@ public required string ItemID } /// - /// Configuration for minimum pricing + /// The pricing model type /// - public required global::Orb.Models.Plans.MinimumConfig MinimumConfig + public JsonElement ModelType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" - ); + return this._rawData.GetNotNullStruct("model_type"); } - init { this._rawData.Set("minimum_config", value); } + init { this._rawData.Set("model_type", value); } } /// - /// The pricing model type + /// The name of the price. /// - public JsonElement ModelType + public required string Name { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); + return this._rawData.GetNotNullClass("name"); } - init { this._rawData.Set("model_type", value); } + init { this._rawData.Set("name", value); } } /// - /// The name of the price. + /// Configuration for percent pricing /// - public required string Name + public required PercentConfig PercentConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); + return this._rawData.GetNotNullClass("percent_config"); } - init { this._rawData.Set("name", value); } + init { this._rawData.Set("percent_config", value); } } /// @@ -6626,12 +6424,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public MinimumConversionRateConfig? ConversionRateConfig + public PercentConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -6762,12 +6560,12 @@ public override void Validate() { this.Cadence.Validate(); _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("percent"))) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; + this.PercentConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -6783,51 +6581,48 @@ public override void Validate() _ = this.ReferenceID; } - public Minimum() + public Percent() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public Minimum(global::Orb.Models.Plans.Minimum minimum) - : base(minimum) { } + public Percent(Percent percent) + : base(percent) { } - public Minimum(IReadOnlyDictionary rawData) + public Percent(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Minimum(FrozenDictionary rawData) + Percent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Percent FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class MinimumFromRaw : IFromRawJson +class PercentFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.Minimum.FromRawUnchecked(rawData); + public Percent FromRawUnchecked(IReadOnlyDictionary rawData) => + Percent.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(MinimumCadenceConverter))] -public enum MinimumCadence +[JsonConverter(typeof(PercentCadenceConverter))] +public enum PercentCadence { Annual, SemiAnnual, @@ -6837,9 +6632,9 @@ public enum MinimumCadence Custom, } -sealed class MinimumCadenceConverter : JsonConverter +sealed class PercentCadenceConverter : JsonConverter { - public override MinimumCadence Read( + public override PercentCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6847,19 +6642,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => MinimumCadence.Annual, - "semi_annual" => MinimumCadence.SemiAnnual, - "monthly" => MinimumCadence.Monthly, - "quarterly" => MinimumCadence.Quarterly, - "one_time" => MinimumCadence.OneTime, - "custom" => MinimumCadence.Custom, - _ => (MinimumCadence)(-1), + "annual" => PercentCadence.Annual, + "semi_annual" => PercentCadence.SemiAnnual, + "monthly" => PercentCadence.Monthly, + "quarterly" => PercentCadence.Quarterly, + "one_time" => PercentCadence.OneTime, + "custom" => PercentCadence.Custom, + _ => (PercentCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - MinimumCadence value, + PercentCadence value, JsonSerializerOptions options ) { @@ -6867,12 +6662,12 @@ JsonSerializerOptions options writer, value switch { - MinimumCadence.Annual => "annual", - MinimumCadence.SemiAnnual => "semi_annual", - MinimumCadence.Monthly => "monthly", - MinimumCadence.Quarterly => "quarterly", - MinimumCadence.OneTime => "one_time", - MinimumCadence.Custom => "custom", + PercentCadence.Annual => "annual", + PercentCadence.SemiAnnual => "semi_annual", + PercentCadence.Monthly => "monthly", + PercentCadence.Quarterly => "quarterly", + PercentCadence.OneTime => "one_time", + PercentCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -6883,808 +6678,33 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for percent pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.MinimumConfig, - global::Orb.Models.Plans.MinimumConfigFromRaw - >) -)] -public sealed record class MinimumConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PercentConfig : JsonModel { /// - /// The minimum amount to apply + /// What percent of the component subtotals to charge /// - public required string MinimumAmount + public required double Percent { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNotNullStruct("percent"); } - init { this._rawData.Set("minimum_amount", value); } + init { this._rawData.Set("percent", value); } } - /// - /// If true, subtotals from this price are prorated based on the service period - /// - public bool? Prorated - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); - } - init - { - if (value == null) - { - return; - } - - this._rawData.Set("prorated", value); - } - } - - /// - public override void Validate() - { - _ = this.MinimumAmount; - _ = this.Prorated; - } - - public MinimumConfig() { } - - public MinimumConfig(global::Orb.Models.Plans.MinimumConfig minimumConfig) - : base(minimumConfig) { } - - public MinimumConfig(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - MinimumConfig(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static global::Orb.Models.Plans.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public MinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } -} - -class MinimumConfigFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Plans.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.MinimumConfig.FromRawUnchecked(rawData); -} - -[JsonConverter(typeof(MinimumConversionRateConfigConverter))] -public record class MinimumConversionRateConfig : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - - public JsonElement Json - { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } - } - - public MinimumConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public MinimumConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public MinimumConversionRateConfig(JsonElement element) - { - this._element = element; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) - { - value = this.Value as SharedUnitConversionRateConfig; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) - { - value = this.Value as SharedTieredConversionRateConfig; - return value != null; - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action unit, - System::Action tiered - ) - { - switch (this.Value) - { - case SharedUnitConversionRateConfig value: - unit(value); - break; - case SharedTieredConversionRateConfig value: - tiered(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" - ); - } - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func unit, - System::Func tiered - ) - { - return this.Value switch - { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" - ), - }; - } - - public static implicit operator MinimumConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); - - public static implicit operator MinimumConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); - - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() - { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" - ); - } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); - } - - public virtual bool Equals(MinimumConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } - - public override int GetHashCode() - { - return 0; - } - - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class MinimumConversionRateConfigConverter : JsonConverter -{ - public override MinimumConversionRateConfig? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; - try - { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); - } - catch - { - conversionRateType = null; - } - - switch (conversionRateType) - { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new MinimumConversionRateConfig(element); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - MinimumConversionRateConfig value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } -} - -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.Percent, - global::Orb.Models.Plans.PercentFromRaw - >) -)] -public sealed record class Percent : JsonModel -{ - /// - /// The cadence to bill for this price on. - /// - public required ApiEnum Cadence - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); - } - init { this._rawData.Set("cadence", value); } - } - - /// - /// The id of the item the price will be associated with. - /// - public required string ItemID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); - } - init { this._rawData.Set("item_id", value); } - } - - /// - /// The pricing model type - /// - public JsonElement ModelType - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); - } - init { this._rawData.Set("model_type", value); } - } - - /// - /// The name of the price. - /// - public required string Name - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } - } - - /// - /// Configuration for percent pricing - /// - public required global::Orb.Models.Plans.PercentConfig PercentConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "percent_config" - ); - } - init { this._rawData.Set("percent_config", value); } - } - - /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. - /// - public string? BillableMetricID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); - } - init { this._rawData.Set("billable_metric_id", value); } - } - - /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. - /// - public bool? BilledInAdvance - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); - } - init { this._rawData.Set("billed_in_advance", value); } - } - - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } - } - - /// - /// The per unit conversion rate of the price currency to the invoicing currency. - /// - public double? ConversionRate - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); - } - init { this._rawData.Set("conversion_rate", value); } - } - - /// - /// The configuration for the rate of the price currency to the invoicing currency. - /// - public global::Orb.Models.Plans.PercentConversionRateConfig? ConversionRateConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", value); } - } - - /// - /// An ISO 4217 currency string, or custom pricing unit identifier, in which - /// this price is billed. - /// - public string? Currency - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("currency"); - } - init { this._rawData.Set("currency", value); } - } - - /// - /// For dimensional price: specifies a price group and dimension values - /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } - } - - /// - /// An alias for the price. - /// - public string? ExternalPriceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } - } - - /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. - /// - public double? FixedPriceQuantity - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } - } - - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", value); } - } - - /// - /// Within each billing cycle, specifies the cadence at which invoices are produced. - /// If unspecified, a single invoice is produced per billing cycle. - /// - public NewBillingCycleConfiguration? InvoicingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); - } - init { this._rawData.Set("invoicing_cycle_configuration", value); } - } - - /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared - /// by setting `metadata` to `null`. - /// - public IReadOnlyDictionary? Metadata - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) - ); - } - } - - /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. - /// - public string? ReferenceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("reference_id"); - } - init { this._rawData.Set("reference_id", value); } - } - - /// - public override void Validate() - { - this.Cadence.Validate(); - _ = this.ItemID; - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("percent"))) - { - throw new OrbInvalidDataException("Invalid value given for constant"); - } - _ = this.Name; - this.PercentConfig.Validate(); - _ = this.BillableMetricID; - _ = this.BilledInAdvance; - this.BillingCycleConfiguration?.Validate(); - _ = this.ConversionRate; - this.ConversionRateConfig?.Validate(); - _ = this.Currency; - this.DimensionalPriceConfiguration?.Validate(); - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.InvoiceGroupingKey; - this.InvoicingCycleConfiguration?.Validate(); - _ = this.Metadata; - _ = this.ReferenceID; - } - - public Percent() - { - this.ModelType = JsonSerializer.SerializeToElement("percent"); - } - - public Percent(global::Orb.Models.Plans.Percent percent) - : base(percent) { } - - public Percent(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("percent"); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Percent(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static global::Orb.Models.Plans.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class PercentFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Plans.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.Percent.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(global::Orb.Models.Plans.PercentCadenceConverter))] -public enum PercentCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class PercentCadenceConverter : JsonConverter -{ - public override global::Orb.Models.Plans.PercentCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => global::Orb.Models.Plans.PercentCadence.Annual, - "semi_annual" => global::Orb.Models.Plans.PercentCadence.SemiAnnual, - "monthly" => global::Orb.Models.Plans.PercentCadence.Monthly, - "quarterly" => global::Orb.Models.Plans.PercentCadence.Quarterly, - "one_time" => global::Orb.Models.Plans.PercentCadence.OneTime, - "custom" => global::Orb.Models.Plans.PercentCadence.Custom, - _ => (global::Orb.Models.Plans.PercentCadence)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Plans.PercentCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - global::Orb.Models.Plans.PercentCadence.Annual => "annual", - global::Orb.Models.Plans.PercentCadence.SemiAnnual => "semi_annual", - global::Orb.Models.Plans.PercentCadence.Monthly => "monthly", - global::Orb.Models.Plans.PercentCadence.Quarterly => "quarterly", - global::Orb.Models.Plans.PercentCadence.OneTime => "one_time", - global::Orb.Models.Plans.PercentCadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} - -/// -/// Configuration for percent pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.PercentConfig, - global::Orb.Models.Plans.PercentConfigFromRaw - >) -)] -public sealed record class PercentConfig : JsonModel -{ - /// - /// What percent of the component subtotals to charge - /// - public required double Percent - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("percent"); - } - init { this._rawData.Set("percent", value); } - } - - /// - public override void Validate() + /// + public override void Validate() { _ = this.Percent; } public PercentConfig() { } - public PercentConfig(global::Orb.Models.Plans.PercentConfig percentConfig) + public PercentConfig(PercentConfig percentConfig) : base(percentConfig) { } public PercentConfig(IReadOnlyDictionary rawData) @@ -7700,10 +6720,8 @@ public PercentConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.PercentConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } @@ -7716,15 +6734,14 @@ public PercentConfig(double percent) } } -class PercentConfigFromRaw : IFromRawJson +class PercentConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.PercentConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.PercentConfig.FromRawUnchecked(rawData); + public PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + PercentConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Plans.PercentConversionRateConfigConverter))] +[JsonConverter(typeof(PercentConversionRateConfigConverter))] public record class PercentConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -7883,11 +6900,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Plans.PercentConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Plans.PercentConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7912,7 +6929,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Plans.PercentConversionRateConfig? other) + public virtual bool Equals(PercentConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -7926,10 +6943,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class PercentConversionRateConfigConverter - : JsonConverter +sealed class PercentConversionRateConfigConverter : JsonConverter { - public override global::Orb.Models.Plans.PercentConversionRateConfig? Read( + public override PercentConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7994,14 +7010,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Plans.PercentConversionRateConfig(element); + return new PercentConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.PercentConversionRateConfig value, + PercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -8009,25 +7025,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.EventOutput, - global::Orb.Models.Plans.EventOutputFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class EventOutput : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } @@ -8035,14 +7044,12 @@ public sealed record class EventOutput : JsonModel /// /// Configuration for event_output pricing /// - public required global::Orb.Models.Plans.EventOutputConfig EventOutputConfig + public required EventOutputConfig EventOutputConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "event_output_config" - ); + return this._rawData.GetNotNullClass("event_output_config"); } init { this._rawData.Set("event_output_config", value); } } @@ -8145,12 +7152,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Plans.EventOutputConversionRateConfig? ConversionRateConfig + public EventOutputConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8312,7 +7319,7 @@ public EventOutput() this.ModelType = JsonSerializer.SerializeToElement("event_output"); } - public EventOutput(global::Orb.Models.Plans.EventOutput eventOutput) + public EventOutput(EventOutput eventOutput) : base(eventOutput) { } public EventOutput(IReadOnlyDictionary rawData) @@ -8330,27 +7337,24 @@ public EventOutput(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.EventOutput FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class EventOutputFromRaw : IFromRawJson +class EventOutputFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.EventOutput FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.EventOutput.FromRawUnchecked(rawData); + public EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutput.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Plans.EventOutputCadenceConverter))] +[JsonConverter(typeof(EventOutputCadenceConverter))] public enum EventOutputCadence { Annual, @@ -8361,10 +7365,9 @@ public enum EventOutputCadence Custom, } -sealed class EventOutputCadenceConverter - : JsonConverter +sealed class EventOutputCadenceConverter : JsonConverter { - public override global::Orb.Models.Plans.EventOutputCadence Read( + public override EventOutputCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8372,19 +7375,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Plans.EventOutputCadence.Annual, - "semi_annual" => global::Orb.Models.Plans.EventOutputCadence.SemiAnnual, - "monthly" => global::Orb.Models.Plans.EventOutputCadence.Monthly, - "quarterly" => global::Orb.Models.Plans.EventOutputCadence.Quarterly, - "one_time" => global::Orb.Models.Plans.EventOutputCadence.OneTime, - "custom" => global::Orb.Models.Plans.EventOutputCadence.Custom, - _ => (global::Orb.Models.Plans.EventOutputCadence)(-1), + "annual" => EventOutputCadence.Annual, + "semi_annual" => EventOutputCadence.SemiAnnual, + "monthly" => EventOutputCadence.Monthly, + "quarterly" => EventOutputCadence.Quarterly, + "one_time" => EventOutputCadence.OneTime, + "custom" => EventOutputCadence.Custom, + _ => (EventOutputCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.EventOutputCadence value, + EventOutputCadence value, JsonSerializerOptions options ) { @@ -8392,12 +7395,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Plans.EventOutputCadence.Annual => "annual", - global::Orb.Models.Plans.EventOutputCadence.SemiAnnual => "semi_annual", - global::Orb.Models.Plans.EventOutputCadence.Monthly => "monthly", - global::Orb.Models.Plans.EventOutputCadence.Quarterly => "quarterly", - global::Orb.Models.Plans.EventOutputCadence.OneTime => "one_time", - global::Orb.Models.Plans.EventOutputCadence.Custom => "custom", + EventOutputCadence.Annual => "annual", + EventOutputCadence.SemiAnnual => "semi_annual", + EventOutputCadence.Monthly => "monthly", + EventOutputCadence.Quarterly => "quarterly", + EventOutputCadence.OneTime => "one_time", + EventOutputCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -8410,12 +7413,7 @@ JsonSerializerOptions options /// /// Configuration for event_output pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.EventOutputConfig, - global::Orb.Models.Plans.EventOutputConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class EventOutputConfig : JsonModel { /// @@ -8470,7 +7468,7 @@ public override void Validate() public EventOutputConfig() { } - public EventOutputConfig(global::Orb.Models.Plans.EventOutputConfig eventOutputConfig) + public EventOutputConfig(EventOutputConfig eventOutputConfig) : base(eventOutputConfig) { } public EventOutputConfig(IReadOnlyDictionary rawData) @@ -8486,8 +7484,8 @@ public EventOutputConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.EventOutputConfig FromRawUnchecked( + /// + public static EventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8502,15 +7500,14 @@ public EventOutputConfig(string unitRatingKey) } } -class EventOutputConfigFromRaw : IFromRawJson +class EventOutputConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.EventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.EventOutputConfig.FromRawUnchecked(rawData); + public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutputConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Plans.EventOutputConversionRateConfigConverter))] +[JsonConverter(typeof(EventOutputConversionRateConfigConverter))] public record class EventOutputConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -8669,11 +7666,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Plans.EventOutputConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Plans.EventOutputConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -8698,7 +7695,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Plans.EventOutputConversionRateConfig? other) + public virtual bool Equals(EventOutputConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -8713,9 +7710,9 @@ public override string ToString() => } sealed class EventOutputConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Plans.EventOutputConversionRateConfig? Read( + public override EventOutputConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8780,14 +7777,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Plans.EventOutputConversionRateConfig(element); + return new EventOutputConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.EventOutputConversionRateConfig value, + EventOutputConversionRateConfig value, JsonSerializerOptions options ) { @@ -8795,7 +7792,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Adjustment : JsonModel { /// @@ -8833,7 +7830,7 @@ public override void Validate() public Adjustment() { } - public Adjustment(global::Orb.Models.Plans.Adjustment adjustment) + public Adjustment(Adjustment adjustment) : base(adjustment) { } public Adjustment(IReadOnlyDictionary rawData) @@ -8850,9 +7847,7 @@ public Adjustment(IReadOnlyDictionary rawData) #pragma warning restore CS8618 /// - public static global::Orb.Models.Plans.Adjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) + public static Adjustment FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } @@ -8865,12 +7860,11 @@ public Adjustment(AdjustmentAdjustment adjustmentValue) } } -class AdjustmentFromRaw : IFromRawJson +class AdjustmentFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.Adjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.Adjustment.FromRawUnchecked(rawData); + public Adjustment FromRawUnchecked(IReadOnlyDictionary rawData) => + Adjustment.FromRawUnchecked(rawData); } /// @@ -9398,14 +8392,12 @@ public long? Duration init { this._rawData.Set("duration", value); } } - public ApiEnum? DurationUnit + public ApiEnum? DurationUnit { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass< - ApiEnum - >("duration_unit"); + return this._rawData.GetNullableClass>("duration_unit"); } init { this._rawData.Set("duration_unit", value); } } @@ -9458,7 +8450,7 @@ public PlanPhase FromRawUnchecked(IReadOnlyDictionary rawDa PlanPhase.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Plans.DurationUnitConverter))] +[JsonConverter(typeof(DurationUnitConverter))] public enum DurationUnit { Daily, @@ -9468,9 +8460,9 @@ public enum DurationUnit Annual, } -sealed class DurationUnitConverter : JsonConverter +sealed class DurationUnitConverter : JsonConverter { - public override global::Orb.Models.Plans.DurationUnit Read( + public override DurationUnit Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9478,18 +8470,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "daily" => global::Orb.Models.Plans.DurationUnit.Daily, - "monthly" => global::Orb.Models.Plans.DurationUnit.Monthly, - "quarterly" => global::Orb.Models.Plans.DurationUnit.Quarterly, - "semi_annual" => global::Orb.Models.Plans.DurationUnit.SemiAnnual, - "annual" => global::Orb.Models.Plans.DurationUnit.Annual, - _ => (global::Orb.Models.Plans.DurationUnit)(-1), + "daily" => DurationUnit.Daily, + "monthly" => DurationUnit.Monthly, + "quarterly" => DurationUnit.Quarterly, + "semi_annual" => DurationUnit.SemiAnnual, + "annual" => DurationUnit.Annual, + _ => (DurationUnit)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.DurationUnit value, + DurationUnit value, JsonSerializerOptions options ) { @@ -9497,11 +8489,11 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Plans.DurationUnit.Daily => "daily", - global::Orb.Models.Plans.DurationUnit.Monthly => "monthly", - global::Orb.Models.Plans.DurationUnit.Quarterly => "quarterly", - global::Orb.Models.Plans.DurationUnit.SemiAnnual => "semi_annual", - global::Orb.Models.Plans.DurationUnit.Annual => "annual", + DurationUnit.Daily => "daily", + DurationUnit.Monthly => "monthly", + DurationUnit.Quarterly => "quarterly", + DurationUnit.SemiAnnual => "semi_annual", + DurationUnit.Annual => "annual", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -9515,16 +8507,16 @@ JsonSerializerOptions options /// The status of the plan to create (either active or draft). If not specified, /// this defaults to active. /// -[JsonConverter(typeof(global::Orb.Models.Plans.StatusConverter))] +[JsonConverter(typeof(StatusConverter))] public enum Status { Active, Draft, } -sealed class StatusConverter : JsonConverter +sealed class StatusConverter : JsonConverter { - public override global::Orb.Models.Plans.Status Read( + public override Status Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9532,24 +8524,20 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "active" => global::Orb.Models.Plans.Status.Active, - "draft" => global::Orb.Models.Plans.Status.Draft, - _ => (global::Orb.Models.Plans.Status)(-1), + "active" => Status.Active, + "draft" => Status.Draft, + _ => (Status)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Plans.Status value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Plans.Status.Active => "active", - global::Orb.Models.Plans.Status.Draft => "draft", + Status.Active => "active", + Status.Draft => "draft", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Plans/PlanFetchParams.cs b/src/Orb/Models/Plans/PlanFetchParams.cs index 9fb892ef..fe3a4fd9 100644 --- a/src/Orb/Models/Plans/PlanFetchParams.cs +++ b/src/Orb/Models/Plans/PlanFetchParams.cs @@ -20,18 +20,25 @@ namespace Orb.Models.Plans; /// /// ## Phases Orb supports plan phases, also known as contract ramps. For plans /// with phases, the serialized prices refer to all prices across all phases. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class PlanFetchParams : ParamsBase +public record class PlanFetchParams : ParamsBase { public string? PlanID { get; init; } public PlanFetchParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PlanFetchParams(PlanFetchParams planFetchParams) : base(planFetchParams) { this.PlanID = planFetchParams.PlanID; } +#pragma warning restore CS8618 public PlanFetchParams( IReadOnlyDictionary rawHeaderData, @@ -66,6 +73,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["PlanID"] = this.PlanID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(PlanFetchParams? other) + { + if (other == null) + { + return false; + } + return (this.PlanID?.Equals(other.PlanID) ?? other.PlanID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -84,4 +113,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Plans/PlanListParams.cs b/src/Orb/Models/Plans/PlanListParams.cs index 33edcf17..e59161cb 100644 --- a/src/Orb/Models/Plans/PlanListParams.cs +++ b/src/Orb/Models/Plans/PlanListParams.cs @@ -15,8 +15,12 @@ namespace Orb.Models.Plans; /// an account in a list format. The list of plans is ordered starting from the most /// recently created plan. The response also includes [`pagination_metadata`](/api-reference/pagination), /// which lets the caller retrieve the next page of results if they exist. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class PlanListParams : ParamsBase +public record class PlanListParams : ParamsBase { public System::DateTimeOffset? CreatedAtGt { @@ -118,8 +122,11 @@ public ApiEnum? Status public PlanListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PlanListParams(PlanListParams planListParams) : base(planListParams) { } +#pragma warning restore CS8618 public PlanListParams( IReadOnlyDictionary rawHeaderData, @@ -154,6 +161,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(PlanListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/plans") @@ -170,6 +197,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// diff --git a/src/Orb/Models/Plans/PlanUpdateParams.cs b/src/Orb/Models/Plans/PlanUpdateParams.cs index 876cd99a..1f6d6f5a 100644 --- a/src/Orb/Models/Plans/PlanUpdateParams.cs +++ b/src/Orb/Models/Plans/PlanUpdateParams.cs @@ -14,8 +14,12 @@ namespace Orb.Models.Plans; /// an existing plan. /// /// Other fields on a plan are currently immutable. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class PlanUpdateParams : ParamsBase +public record class PlanUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -65,6 +69,8 @@ public string? ExternalPlanID public PlanUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PlanUpdateParams(PlanUpdateParams planUpdateParams) : base(planUpdateParams) { @@ -72,6 +78,7 @@ public PlanUpdateParams(PlanUpdateParams planUpdateParams) this._rawBodyData = new(planUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public PlanUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -112,6 +119,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["PlanID"] = this.PlanID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(PlanUpdateParams? other) + { + if (other == null) + { + return false; + } + return (this.PlanID?.Equals(other.PlanID) ?? other.PlanID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -139,4 +170,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Price.cs b/src/Orb/Models/Price.cs index 9a7e0221..f71357d6 100644 --- a/src/Orb/Models/Price.cs +++ b/src/Orb/Models/Price.cs @@ -72,7 +72,6 @@ public string ID scalableMatrixWithTieredPricing: (x) => x.ID, cumulativeGroupedBulk: (x) => x.ID, cumulativeGroupedAllocation: (x) => x.ID, - minimum: (x) => x.ID, minimumComposite: (x) => x.ID, percent: (x) => x.ID, eventOutput: (x) => x.ID @@ -113,7 +112,6 @@ public BillableMetricTiny? BillableMetric scalableMatrixWithTieredPricing: (x) => x.BillableMetric, cumulativeGroupedBulk: (x) => x.BillableMetric, cumulativeGroupedAllocation: (x) => x.BillableMetric, - minimum: (x) => x.BillableMetric, minimumComposite: (x) => x.BillableMetric, percent: (x) => x.BillableMetric, eventOutput: (x) => x.BillableMetric @@ -154,7 +152,6 @@ public BillingCycleConfiguration BillingCycleConfiguration scalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, cumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, minimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration @@ -195,7 +192,6 @@ public double? ConversionRate scalableMatrixWithTieredPricing: (x) => x.ConversionRate, cumulativeGroupedBulk: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, minimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate @@ -236,7 +232,6 @@ public double? ConversionRate scalableMatrixWithTieredPricing: (x) => x.CreatedAt, cumulativeGroupedBulk: (x) => x.CreatedAt, cumulativeGroupedAllocation: (x) => x.CreatedAt, - minimum: (x) => x.CreatedAt, minimumComposite: (x) => x.CreatedAt, percent: (x) => x.CreatedAt, eventOutput: (x) => x.CreatedAt @@ -277,7 +272,6 @@ public Allocation? CreditAllocation scalableMatrixWithTieredPricing: (x) => x.CreditAllocation, cumulativeGroupedBulk: (x) => x.CreditAllocation, cumulativeGroupedAllocation: (x) => x.CreditAllocation, - minimum: (x) => x.CreditAllocation, minimumComposite: (x) => x.CreditAllocation, percent: (x) => x.CreditAllocation, eventOutput: (x) => x.CreditAllocation @@ -318,7 +312,6 @@ public string Currency scalableMatrixWithTieredPricing: (x) => x.Currency, cumulativeGroupedBulk: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, minimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency @@ -359,7 +352,6 @@ public SharedDiscount? Discount scalableMatrixWithTieredPricing: (x) => x.Discount, cumulativeGroupedBulk: (x) => x.Discount, cumulativeGroupedAllocation: (x) => x.Discount, - minimum: (x) => x.Discount, minimumComposite: (x) => x.Discount, percent: (x) => x.Discount, eventOutput: (x) => x.Discount @@ -400,7 +392,6 @@ public string? ExternalPriceID scalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, cumulativeGroupedBulk: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, minimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID @@ -441,7 +432,6 @@ public double? FixedPriceQuantity scalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, cumulativeGroupedBulk: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, minimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity @@ -482,7 +472,6 @@ public BillingCycleConfiguration? InvoicingCycleConfiguration scalableMatrixWithTieredPricing: (x) => x.InvoicingCycleConfiguration, cumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, minimumComposite: (x) => x.InvoicingCycleConfiguration, percent: (x) => x.InvoicingCycleConfiguration, eventOutput: (x) => x.InvoicingCycleConfiguration @@ -523,7 +512,6 @@ public ItemSlim Item scalableMatrixWithTieredPricing: (x) => x.Item, cumulativeGroupedBulk: (x) => x.Item, cumulativeGroupedAllocation: (x) => x.Item, - minimum: (x) => x.Item, minimumComposite: (x) => x.Item, percent: (x) => x.Item, eventOutput: (x) => x.Item @@ -564,7 +552,6 @@ public Maximum? Maximum scalableMatrixWithTieredPricing: (x) => x.Maximum, cumulativeGroupedBulk: (x) => x.Maximum, cumulativeGroupedAllocation: (x) => x.Maximum, - minimum: (x) => x.Maximum, minimumComposite: (x) => x.Maximum, percent: (x) => x.Maximum, eventOutput: (x) => x.Maximum @@ -605,7 +592,6 @@ public string? MaximumAmount scalableMatrixWithTieredPricing: (x) => x.MaximumAmount, cumulativeGroupedBulk: (x) => x.MaximumAmount, cumulativeGroupedAllocation: (x) => x.MaximumAmount, - minimum: (x) => x.MaximumAmount, minimumComposite: (x) => x.MaximumAmount, percent: (x) => x.MaximumAmount, eventOutput: (x) => x.MaximumAmount @@ -646,7 +632,6 @@ public Minimum? Minimum scalableMatrixWithTieredPricing: (x) => x.Minimum, cumulativeGroupedBulk: (x) => x.Minimum, cumulativeGroupedAllocation: (x) => x.Minimum, - minimum: (x) => x.Minimum, minimumComposite: (x) => x.Minimum, percent: (x) => x.Minimum, eventOutput: (x) => x.Minimum @@ -687,7 +672,6 @@ public string? MinimumAmount scalableMatrixWithTieredPricing: (x) => x.MinimumAmount, cumulativeGroupedBulk: (x) => x.MinimumAmount, cumulativeGroupedAllocation: (x) => x.MinimumAmount, - minimum: (x) => x.MinimumAmount, minimumComposite: (x) => x.MinimumAmount, percent: (x) => x.MinimumAmount, eventOutput: (x) => x.MinimumAmount @@ -728,7 +712,6 @@ public JsonElement ModelType scalableMatrixWithTieredPricing: (x) => x.ModelType, cumulativeGroupedBulk: (x) => x.ModelType, cumulativeGroupedAllocation: (x) => x.ModelType, - minimum: (x) => x.ModelType, minimumComposite: (x) => x.ModelType, percent: (x) => x.ModelType, eventOutput: (x) => x.ModelType @@ -769,7 +752,6 @@ public string Name scalableMatrixWithTieredPricing: (x) => x.Name, cumulativeGroupedBulk: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, minimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name @@ -810,7 +792,6 @@ public long? PlanPhaseOrder scalableMatrixWithTieredPricing: (x) => x.PlanPhaseOrder, cumulativeGroupedBulk: (x) => x.PlanPhaseOrder, cumulativeGroupedAllocation: (x) => x.PlanPhaseOrder, - minimum: (x) => x.PlanPhaseOrder, minimumComposite: (x) => x.PlanPhaseOrder, percent: (x) => x.PlanPhaseOrder, eventOutput: (x) => x.PlanPhaseOrder @@ -851,7 +832,6 @@ public string? ReplacesPriceID scalableMatrixWithTieredPricing: (x) => x.ReplacesPriceID, cumulativeGroupedBulk: (x) => x.ReplacesPriceID, cumulativeGroupedAllocation: (x) => x.ReplacesPriceID, - minimum: (x) => x.ReplacesPriceID, minimumComposite: (x) => x.ReplacesPriceID, percent: (x) => x.ReplacesPriceID, eventOutput: (x) => x.ReplacesPriceID @@ -892,7 +872,6 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration scalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, minimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration @@ -1068,12 +1047,6 @@ public Price(CumulativeGroupedAllocation value, JsonElement? element = null) this._element = element; } - public Price(PriceMinimum value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - public Price(MinimumComposite value, JsonElement? element = null) { this.Value = value; @@ -1699,27 +1672,6 @@ public bool TryPickCumulativeGroupedAllocation( return value != null; } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `PriceMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum([NotNullWhen(true)] out PriceMinimum? value) - { - value = this.Value as PriceMinimum; - return value != null; - } - /// /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . @@ -1825,7 +1777,6 @@ public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) /// (ScalableMatrixWithTieredPricing value) => {...}, /// (CumulativeGroupedBulk value) => {...}, /// (CumulativeGroupedAllocation value) => {...}, - /// (PriceMinimum value) => {...}, /// (MinimumComposite value) => {...}, /// (Percent value) => {...}, /// (EventOutput value) => {...} @@ -1862,7 +1813,6 @@ public void Switch( System::Action scalableMatrixWithTieredPricing, System::Action cumulativeGroupedBulk, System::Action cumulativeGroupedAllocation, - System::Action minimum, System::Action minimumComposite, System::Action percent, System::Action eventOutput @@ -1954,9 +1904,6 @@ public void Switch( case CumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case PriceMinimum value: - minimum(value); - break; case MinimumComposite value: minimumComposite(value); break; @@ -2014,7 +1961,6 @@ public void Switch( /// (ScalableMatrixWithTieredPricing value) => {...}, /// (CumulativeGroupedBulk value) => {...}, /// (CumulativeGroupedAllocation value) => {...}, - /// (PriceMinimum value) => {...}, /// (MinimumComposite value) => {...}, /// (Percent value) => {...}, /// (EventOutput value) => {...} @@ -2051,7 +1997,6 @@ public T Match( System::Func scalableMatrixWithTieredPricing, System::Func cumulativeGroupedBulk, System::Func cumulativeGroupedAllocation, - System::Func minimum, System::Func minimumComposite, System::Func percent, System::Func eventOutput @@ -2087,7 +2032,6 @@ public T Match( ScalableMatrixWithTieredPricing value => scalableMatrixWithTieredPricing(value), CumulativeGroupedBulk value => cumulativeGroupedBulk(value), CumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - PriceMinimum value => minimum(value), MinimumComposite value => minimumComposite(value), Percent value => percent(value), EventOutput value => eventOutput(value), @@ -2151,8 +2095,6 @@ public T Match( public static implicit operator Price(CumulativeGroupedAllocation value) => new(value); - public static implicit operator Price(PriceMinimum value) => new(value); - public static implicit operator Price(MinimumComposite value) => new(value); public static implicit operator Price(Percent value) => new(value); @@ -2204,7 +2146,6 @@ public override void Validate() (scalableMatrixWithTieredPricing) => scalableMatrixWithTieredPricing.Validate(), (cumulativeGroupedBulk) => cumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), (minimumComposite) => minimumComposite.Validate(), (percent) => percent.Validate(), (eventOutput) => eventOutput.Validate() @@ -2841,25 +2782,6 @@ JsonSerializerOptions options return new(element); } - case "minimum": - { - try - { - var deserialized = JsonSerializer.Deserialize(element, options); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } case "minimum_composite": { try @@ -26656,1233 +26578,42 @@ public required BillingCycleConfiguration BillingCycleConfiguration init { this._rawData.Set("billing_cycle_configuration", value); } } - public required ApiEnum BillingMode - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("billing_mode"); - } - init { this._rawData.Set("billing_mode", value); } - } - - public required ApiEnum Cadence - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); - } - init { this._rawData.Set("cadence", value); } - } - - public required IReadOnlyList? CompositePriceFilters - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct< - ImmutableArray - >("composite_price_filters"); - } - init - { - this._rawData.Set?>( - "composite_price_filters", - value == null ? null : ImmutableArray.ToImmutableArray(value) - ); - } - } - - public required double? ConversionRate - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); - } - init { this._rawData.Set("conversion_rate", value); } - } - - public required GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", value); } - } - - public required System::DateTimeOffset CreatedAt - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("created_at"); - } - init { this._rawData.Set("created_at", value); } - } - - public required Allocation? CreditAllocation - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("credit_allocation"); - } - init { this._rawData.Set("credit_allocation", value); } - } - - public required string Currency - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("currency"); - } - init { this._rawData.Set("currency", value); } - } - - [System::Obsolete("deprecated")] - public required SharedDiscount? Discount - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("discount"); - } - init { this._rawData.Set("discount", value); } - } - - public required string? ExternalPriceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } - } - - public required double? FixedPriceQuantity - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } - } - - /// - /// Configuration for grouped_with_min_max_thresholds pricing - /// - public required GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_with_min_max_thresholds_config" - ); - } - init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } - } - - public required BillingCycleConfiguration? InvoicingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); - } - init { this._rawData.Set("invoicing_cycle_configuration", value); } - } - - /// - /// A minimal representation of an Item containing only the essential identifying information. - /// - public required ItemSlim Item - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item"); - } - init { this._rawData.Set("item", value); } - } - - [System::Obsolete("deprecated")] - public required Maximum? Maximum - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("maximum"); - } - init { this._rawData.Set("maximum", value); } - } - - [System::Obsolete("deprecated")] - public required string? MaximumAmount - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("maximum_amount"); - } - init { this._rawData.Set("maximum_amount", value); } - } - - /// - /// User specified key-value pairs for the resource. If not present, this defaults - /// to an empty dictionary. Individual keys can be removed by setting the value - /// to `null`, and the entire metadata mapping can be cleared by setting `metadata` - /// to `null`. - /// - public required IReadOnlyDictionary Metadata - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass>("metadata"); - } - init - { - this._rawData.Set>( - "metadata", - FrozenDictionary.ToFrozenDictionary(value) - ); - } - } - - [System::Obsolete("deprecated")] - public required Minimum? Minimum - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("minimum"); - } - init { this._rawData.Set("minimum", value); } - } - - [System::Obsolete("deprecated")] - public required string? MinimumAmount - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("minimum_amount"); - } - init { this._rawData.Set("minimum_amount", value); } - } - - /// - /// The pricing model type - /// - public JsonElement ModelType - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); - } - init { this._rawData.Set("model_type", value); } - } - - public required string Name - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } - } - - public required long? PlanPhaseOrder - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); - } - init { this._rawData.Set("plan_phase_order", value); } - } - - public required ApiEnum PriceType - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("price_type"); - } - init { this._rawData.Set("price_type", value); } - } - - /// - /// The price id this price replaces. This price will take the place of the replaced - /// price in plan version migrations. - /// - public required string? ReplacesPriceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("replaces_price_id"); - } - init { this._rawData.Set("replaces_price_id", value); } - } - - public DimensionalPriceConfiguration? DimensionalPriceConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } - } - - /// - public override void Validate() - { - _ = this.ID; - this.BillableMetric?.Validate(); - this.BillingCycleConfiguration.Validate(); - this.BillingMode.Validate(); - this.Cadence.Validate(); - foreach (var item in this.CompositePriceFilters ?? []) - { - item.Validate(); - } - _ = this.ConversionRate; - this.ConversionRateConfig?.Validate(); - _ = this.CreatedAt; - this.CreditAllocation?.Validate(); - _ = this.Currency; - this.Discount?.Validate(); - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - this.GroupedWithMinMaxThresholdsConfig.Validate(); - this.InvoicingCycleConfiguration?.Validate(); - this.Item.Validate(); - this.Maximum?.Validate(); - _ = this.MaximumAmount; - _ = this.Metadata; - this.Minimum?.Validate(); - _ = this.MinimumAmount; - if ( - !JsonElement.DeepEquals( - this.ModelType, - JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") - ) - ) - { - throw new OrbInvalidDataException("Invalid value given for constant"); - } - _ = this.Name; - _ = this.PlanPhaseOrder; - this.PriceType.Validate(); - _ = this.ReplacesPriceID; - this.DimensionalPriceConfiguration?.Validate(); - } - - [System::Obsolete( - "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" - )] - public GroupedWithMinMaxThresholds() - { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); - } - - [System::Obsolete( - "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" - )] - public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) - : base(groupedWithMinMaxThresholds) { } - - [System::Obsolete( - "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" - )] - public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); - } - -#pragma warning disable CS8618 - [System::Obsolete( - "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" - )] - [SetsRequiredMembers] - GroupedWithMinMaxThresholds(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static GroupedWithMinMaxThresholds FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class GroupedWithMinMaxThresholdsFromRaw : IFromRawJson -{ - /// - public GroupedWithMinMaxThresholds FromRawUnchecked( - IReadOnlyDictionary rawData - ) => GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); -} - -[JsonConverter(typeof(GroupedWithMinMaxThresholdsBillingModeConverter))] -public enum GroupedWithMinMaxThresholdsBillingMode -{ - InAdvance, - InArrear, -} - -sealed class GroupedWithMinMaxThresholdsBillingModeConverter - : JsonConverter -{ - public override GroupedWithMinMaxThresholdsBillingMode Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "in_advance" => GroupedWithMinMaxThresholdsBillingMode.InAdvance, - "in_arrear" => GroupedWithMinMaxThresholdsBillingMode.InArrear, - _ => (GroupedWithMinMaxThresholdsBillingMode)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - GroupedWithMinMaxThresholdsBillingMode value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - GroupedWithMinMaxThresholdsBillingMode.InAdvance => "in_advance", - GroupedWithMinMaxThresholdsBillingMode.InArrear => "in_arrear", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} - -[JsonConverter(typeof(GroupedWithMinMaxThresholdsCadenceConverter))] -public enum GroupedWithMinMaxThresholdsCadence -{ - OneTime, - Monthly, - Quarterly, - SemiAnnual, - Annual, - Custom, -} - -sealed class GroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter -{ - public override GroupedWithMinMaxThresholdsCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "one_time" => GroupedWithMinMaxThresholdsCadence.OneTime, - "monthly" => GroupedWithMinMaxThresholdsCadence.Monthly, - "quarterly" => GroupedWithMinMaxThresholdsCadence.Quarterly, - "semi_annual" => GroupedWithMinMaxThresholdsCadence.SemiAnnual, - "annual" => GroupedWithMinMaxThresholdsCadence.Annual, - "custom" => GroupedWithMinMaxThresholdsCadence.Custom, - _ => (GroupedWithMinMaxThresholdsCadence)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - GroupedWithMinMaxThresholdsCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - GroupedWithMinMaxThresholdsCadence.OneTime => "one_time", - GroupedWithMinMaxThresholdsCadence.Monthly => "monthly", - GroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", - GroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", - GroupedWithMinMaxThresholdsCadence.Annual => "annual", - GroupedWithMinMaxThresholdsCadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} - -[JsonConverter( - typeof(JsonModelConverter< - GroupedWithMinMaxThresholdsCompositePriceFilter, - GroupedWithMinMaxThresholdsCompositePriceFilterFromRaw - >) -)] -public sealed record class GroupedWithMinMaxThresholdsCompositePriceFilter : JsonModel -{ - /// - /// The property of the price to filter on. - /// - public required ApiEnum Field - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("field"); - } - init { this._rawData.Set("field", value); } - } - - /// - /// Should prices that match the filter be included or excluded. - /// - public required ApiEnum< - string, - GroupedWithMinMaxThresholdsCompositePriceFilterOperator - > Operator - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("operator"); - } - init { this._rawData.Set("operator", value); } - } - - /// - /// The IDs or values that match this filter. - /// - public required IReadOnlyList Values - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct>("values"); - } - init - { - this._rawData.Set>( - "values", - ImmutableArray.ToImmutableArray(value) - ); - } - } - - /// - public override void Validate() - { - this.Field.Validate(); - this.Operator.Validate(); - _ = this.Values; - } - - public GroupedWithMinMaxThresholdsCompositePriceFilter() { } - - public GroupedWithMinMaxThresholdsCompositePriceFilter( - GroupedWithMinMaxThresholdsCompositePriceFilter groupedWithMinMaxThresholdsCompositePriceFilter - ) - : base(groupedWithMinMaxThresholdsCompositePriceFilter) { } - - public GroupedWithMinMaxThresholdsCompositePriceFilter( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - GroupedWithMinMaxThresholdsCompositePriceFilter(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static GroupedWithMinMaxThresholdsCompositePriceFilter FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class GroupedWithMinMaxThresholdsCompositePriceFilterFromRaw - : IFromRawJson -{ - /// - public GroupedWithMinMaxThresholdsCompositePriceFilter FromRawUnchecked( - IReadOnlyDictionary rawData - ) => GroupedWithMinMaxThresholdsCompositePriceFilter.FromRawUnchecked(rawData); -} - -/// -/// The property of the price to filter on. -/// -[JsonConverter(typeof(GroupedWithMinMaxThresholdsCompositePriceFilterFieldConverter))] -public enum GroupedWithMinMaxThresholdsCompositePriceFilterField -{ - PriceID, - ItemID, - PriceType, - Currency, - PricingUnitID, -} - -sealed class GroupedWithMinMaxThresholdsCompositePriceFilterFieldConverter - : JsonConverter -{ - public override GroupedWithMinMaxThresholdsCompositePriceFilterField Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "price_id" => GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, - "item_id" => GroupedWithMinMaxThresholdsCompositePriceFilterField.ItemID, - "price_type" => GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceType, - "currency" => GroupedWithMinMaxThresholdsCompositePriceFilterField.Currency, - "pricing_unit_id" => GroupedWithMinMaxThresholdsCompositePriceFilterField.PricingUnitID, - _ => (GroupedWithMinMaxThresholdsCompositePriceFilterField)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - GroupedWithMinMaxThresholdsCompositePriceFilterField value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID => "price_id", - GroupedWithMinMaxThresholdsCompositePriceFilterField.ItemID => "item_id", - GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceType => "price_type", - GroupedWithMinMaxThresholdsCompositePriceFilterField.Currency => "currency", - GroupedWithMinMaxThresholdsCompositePriceFilterField.PricingUnitID => - "pricing_unit_id", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} - -/// -/// Should prices that match the filter be included or excluded. -/// -[JsonConverter(typeof(GroupedWithMinMaxThresholdsCompositePriceFilterOperatorConverter))] -public enum GroupedWithMinMaxThresholdsCompositePriceFilterOperator -{ - Includes, - Excludes, -} - -sealed class GroupedWithMinMaxThresholdsCompositePriceFilterOperatorConverter - : JsonConverter -{ - public override GroupedWithMinMaxThresholdsCompositePriceFilterOperator Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "includes" => GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, - "excludes" => GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Excludes, - _ => (GroupedWithMinMaxThresholdsCompositePriceFilterOperator)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - GroupedWithMinMaxThresholdsCompositePriceFilterOperator value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes => "includes", - GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Excludes => "excludes", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} - -[JsonConverter(typeof(GroupedWithMinMaxThresholdsConversionRateConfigConverter))] -public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - - public JsonElement Json - { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } - } - - public GroupedWithMinMaxThresholdsConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public GroupedWithMinMaxThresholdsConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) - { - this._element = element; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) - { - value = this.Value as SharedUnitConversionRateConfig; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) - { - value = this.Value as SharedTieredConversionRateConfig; - return value != null; - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action unit, - System::Action tiered - ) - { - switch (this.Value) - { - case SharedUnitConversionRateConfig value: - unit(value); - break; - case SharedTieredConversionRateConfig value: - tiered(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" - ); - } - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func unit, - System::Func tiered - ) - { - return this.Value switch - { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" - ), - }; - } - - public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); - - public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); - - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() - { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" - ); - } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); - } - - public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } - - public override int GetHashCode() - { - return 0; - } - - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter -{ - public override GroupedWithMinMaxThresholdsConversionRateConfig? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; - try - { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); - } - catch - { - conversionRateType = null; - } - - switch (conversionRateType) - { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new GroupedWithMinMaxThresholdsConversionRateConfig(element); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - GroupedWithMinMaxThresholdsConversionRateConfig value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } -} - -/// -/// Configuration for grouped_with_min_max_thresholds pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - GroupedWithMinMaxThresholdsConfig, - GroupedWithMinMaxThresholdsConfigFromRaw - >) -)] -public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel -{ - /// - /// The event property used to group before applying thresholds - /// - public required string GroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); - } - init { this._rawData.Set("grouping_key", value); } - } - - /// - /// The maximum amount to charge each group - /// - public required string MaximumCharge - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); - } - init { this._rawData.Set("maximum_charge", value); } - } - - /// - /// The minimum amount to charge each group, regardless of usage - /// - public required string MinimumCharge - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); - } - init { this._rawData.Set("minimum_charge", value); } - } - - /// - /// The base price charged per group - /// - public required string PerUnitRate - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("per_unit_rate"); - } - init { this._rawData.Set("per_unit_rate", value); } - } - - /// - public override void Validate() - { - _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; - } - - public GroupedWithMinMaxThresholdsConfig() { } - - public GroupedWithMinMaxThresholdsConfig( - GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig - ) - : base(groupedWithMinMaxThresholdsConfig) { } - - public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - GroupedWithMinMaxThresholdsConfig(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class GroupedWithMinMaxThresholdsConfigFromRaw : IFromRawJson -{ - /// - public GroupedWithMinMaxThresholdsConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); -} - -[JsonConverter(typeof(GroupedWithMinMaxThresholdsPriceTypeConverter))] -public enum GroupedWithMinMaxThresholdsPriceType -{ - UsagePrice, - FixedPrice, - CompositePrice, -} - -sealed class GroupedWithMinMaxThresholdsPriceTypeConverter - : JsonConverter -{ - public override GroupedWithMinMaxThresholdsPriceType Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "usage_price" => GroupedWithMinMaxThresholdsPriceType.UsagePrice, - "fixed_price" => GroupedWithMinMaxThresholdsPriceType.FixedPrice, - "composite_price" => GroupedWithMinMaxThresholdsPriceType.CompositePrice, - _ => (GroupedWithMinMaxThresholdsPriceType)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - GroupedWithMinMaxThresholdsPriceType value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - GroupedWithMinMaxThresholdsPriceType.UsagePrice => "usage_price", - GroupedWithMinMaxThresholdsPriceType.FixedPrice => "fixed_price", - GroupedWithMinMaxThresholdsPriceType.CompositePrice => "composite_price", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} - -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class MatrixWithDisplayName : JsonModel -{ - public required string ID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("id"); - } - init { this._rawData.Set("id", value); } - } - - public required BillableMetricTiny? BillableMetric - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric"); - } - init { this._rawData.Set("billable_metric", value); } - } - - public required BillingCycleConfiguration BillingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } - } - - public required ApiEnum BillingMode + public required ApiEnum BillingMode { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( - "billing_mode" - ); + return this._rawData.GetNotNullClass< + ApiEnum + >("billing_mode"); } init { this._rawData.Set("billing_mode", value); } } - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( - "cadence" - ); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); } init { this._rawData.Set("cadence", value); } } - public required IReadOnlyList? CompositePriceFilters + public required IReadOnlyList? CompositePriceFilters { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("composite_price_filters"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "composite_price_filters", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -27899,12 +26630,12 @@ public required double? ConversionRate init { this._rawData.Set("conversion_rate", value); } } - public required MatrixWithDisplayNameConversionRateConfig? ConversionRateConfig + public required GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -27972,6 +26703,21 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + /// + /// Configuration for grouped_with_min_max_thresholds pricing + /// + public required GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_with_min_max_thresholds_config" + ); + } + init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -27997,21 +26743,6 @@ public required ItemSlim Item init { this._rawData.Set("item", value); } } - /// - /// Configuration for matrix_with_display_name pricing - /// - public required MatrixWithDisplayNameMatrixWithDisplayNameConfig MatrixWithDisplayNameConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "matrix_with_display_name_config" - ); - } - init { this._rawData.Set("matrix_with_display_name_config", value); } - } - [System::Obsolete("deprecated")] public required Maximum? Maximum { @@ -28111,14 +26842,14 @@ public required long? PlanPhaseOrder init { this._rawData.Set("plan_phase_order", value); } } - public required ApiEnum PriceType + public required ApiEnum PriceType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( - "price_type" - ); + return this._rawData.GetNotNullClass< + ApiEnum + >("price_type"); } init { this._rawData.Set("price_type", value); } } @@ -28169,9 +26900,9 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + this.GroupedWithMinMaxThresholdsConfig.Validate(); this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); - this.MatrixWithDisplayNameConfig.Validate(); this.Maximum?.Validate(); _ = this.MaximumAmount; _ = this.Metadata; @@ -28180,7 +26911,7 @@ public override void Validate() if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("matrix_with_display_name") + JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") ) ) { @@ -28196,25 +26927,25 @@ public override void Validate() [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public MatrixWithDisplayName() + public GroupedWithMinMaxThresholds() { - this.ModelType = JsonSerializer.SerializeToElement("matrix_with_display_name"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public MatrixWithDisplayName(MatrixWithDisplayName matrixWithDisplayName) - : base(matrixWithDisplayName) { } + public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) + : base(groupedWithMinMaxThresholds) { } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public MatrixWithDisplayName(IReadOnlyDictionary rawData) + public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("matrix_with_display_name"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } #pragma warning disable CS8618 @@ -28222,14 +26953,14 @@ public MatrixWithDisplayName(IReadOnlyDictionary rawData) "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] [SetsRequiredMembers] - MatrixWithDisplayName(FrozenDictionary rawData) + GroupedWithMinMaxThresholds(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static MatrixWithDisplayName FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -28237,25 +26968,25 @@ IReadOnlyDictionary rawData } } -class MatrixWithDisplayNameFromRaw : IFromRawJson +class GroupedWithMinMaxThresholdsFromRaw : IFromRawJson { /// - public MatrixWithDisplayName FromRawUnchecked( + public GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => MatrixWithDisplayName.FromRawUnchecked(rawData); + ) => GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } -[JsonConverter(typeof(MatrixWithDisplayNameBillingModeConverter))] -public enum MatrixWithDisplayNameBillingMode +[JsonConverter(typeof(GroupedWithMinMaxThresholdsBillingModeConverter))] +public enum GroupedWithMinMaxThresholdsBillingMode { InAdvance, InArrear, } -sealed class MatrixWithDisplayNameBillingModeConverter - : JsonConverter +sealed class GroupedWithMinMaxThresholdsBillingModeConverter + : JsonConverter { - public override MatrixWithDisplayNameBillingMode Read( + public override GroupedWithMinMaxThresholdsBillingMode Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -28263,15 +26994,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "in_advance" => MatrixWithDisplayNameBillingMode.InAdvance, - "in_arrear" => MatrixWithDisplayNameBillingMode.InArrear, - _ => (MatrixWithDisplayNameBillingMode)(-1), + "in_advance" => GroupedWithMinMaxThresholdsBillingMode.InAdvance, + "in_arrear" => GroupedWithMinMaxThresholdsBillingMode.InArrear, + _ => (GroupedWithMinMaxThresholdsBillingMode)(-1), }; } public override void Write( Utf8JsonWriter writer, - MatrixWithDisplayNameBillingMode value, + GroupedWithMinMaxThresholdsBillingMode value, JsonSerializerOptions options ) { @@ -28279,8 +27010,8 @@ JsonSerializerOptions options writer, value switch { - MatrixWithDisplayNameBillingMode.InAdvance => "in_advance", - MatrixWithDisplayNameBillingMode.InArrear => "in_arrear", + GroupedWithMinMaxThresholdsBillingMode.InAdvance => "in_advance", + GroupedWithMinMaxThresholdsBillingMode.InArrear => "in_arrear", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -28290,8 +27021,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(MatrixWithDisplayNameCadenceConverter))] -public enum MatrixWithDisplayNameCadence +[JsonConverter(typeof(GroupedWithMinMaxThresholdsCadenceConverter))] +public enum GroupedWithMinMaxThresholdsCadence { OneTime, Monthly, @@ -28301,9 +27032,10 @@ public enum MatrixWithDisplayNameCadence Custom, } -sealed class MatrixWithDisplayNameCadenceConverter : JsonConverter +sealed class GroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter { - public override MatrixWithDisplayNameCadence Read( + public override GroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -28311,19 +27043,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "one_time" => MatrixWithDisplayNameCadence.OneTime, - "monthly" => MatrixWithDisplayNameCadence.Monthly, - "quarterly" => MatrixWithDisplayNameCadence.Quarterly, - "semi_annual" => MatrixWithDisplayNameCadence.SemiAnnual, - "annual" => MatrixWithDisplayNameCadence.Annual, - "custom" => MatrixWithDisplayNameCadence.Custom, - _ => (MatrixWithDisplayNameCadence)(-1), + "one_time" => GroupedWithMinMaxThresholdsCadence.OneTime, + "monthly" => GroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => GroupedWithMinMaxThresholdsCadence.Quarterly, + "semi_annual" => GroupedWithMinMaxThresholdsCadence.SemiAnnual, + "annual" => GroupedWithMinMaxThresholdsCadence.Annual, + "custom" => GroupedWithMinMaxThresholdsCadence.Custom, + _ => (GroupedWithMinMaxThresholdsCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - MatrixWithDisplayNameCadence value, + GroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -28331,12 +27063,12 @@ JsonSerializerOptions options writer, value switch { - MatrixWithDisplayNameCadence.OneTime => "one_time", - MatrixWithDisplayNameCadence.Monthly => "monthly", - MatrixWithDisplayNameCadence.Quarterly => "quarterly", - MatrixWithDisplayNameCadence.SemiAnnual => "semi_annual", - MatrixWithDisplayNameCadence.Annual => "annual", - MatrixWithDisplayNameCadence.Custom => "custom", + GroupedWithMinMaxThresholdsCadence.OneTime => "one_time", + GroupedWithMinMaxThresholdsCadence.Monthly => "monthly", + GroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", + GroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", + GroupedWithMinMaxThresholdsCadence.Annual => "annual", + GroupedWithMinMaxThresholdsCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -28348,22 +27080,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - MatrixWithDisplayNameCompositePriceFilter, - MatrixWithDisplayNameCompositePriceFilterFromRaw + GroupedWithMinMaxThresholdsCompositePriceFilter, + GroupedWithMinMaxThresholdsCompositePriceFilterFromRaw >) )] -public sealed record class MatrixWithDisplayNameCompositePriceFilter : JsonModel +public sealed record class GroupedWithMinMaxThresholdsCompositePriceFilter : JsonModel { /// /// The property of the price to filter on. /// - public required ApiEnum Field + public required ApiEnum Field { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("field"); } init { this._rawData.Set("field", value); } @@ -28372,13 +27104,16 @@ public required ApiEnum /// /// Should prices that match the filter be included or excluded. /// - public required ApiEnum Operator + public required ApiEnum< + string, + GroupedWithMinMaxThresholdsCompositePriceFilterOperator + > Operator { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("operator"); } init { this._rawData.Set("operator", value); } @@ -28411,14 +27146,14 @@ public override void Validate() _ = this.Values; } - public MatrixWithDisplayNameCompositePriceFilter() { } + public GroupedWithMinMaxThresholdsCompositePriceFilter() { } - public MatrixWithDisplayNameCompositePriceFilter( - MatrixWithDisplayNameCompositePriceFilter matrixWithDisplayNameCompositePriceFilter + public GroupedWithMinMaxThresholdsCompositePriceFilter( + GroupedWithMinMaxThresholdsCompositePriceFilter groupedWithMinMaxThresholdsCompositePriceFilter ) - : base(matrixWithDisplayNameCompositePriceFilter) { } + : base(groupedWithMinMaxThresholdsCompositePriceFilter) { } - public MatrixWithDisplayNameCompositePriceFilter( + public GroupedWithMinMaxThresholdsCompositePriceFilter( IReadOnlyDictionary rawData ) { @@ -28427,14 +27162,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - MatrixWithDisplayNameCompositePriceFilter(FrozenDictionary rawData) + GroupedWithMinMaxThresholdsCompositePriceFilter(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static MatrixWithDisplayNameCompositePriceFilter FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -28442,20 +27177,20 @@ IReadOnlyDictionary rawData } } -class MatrixWithDisplayNameCompositePriceFilterFromRaw - : IFromRawJson +class GroupedWithMinMaxThresholdsCompositePriceFilterFromRaw + : IFromRawJson { /// - public MatrixWithDisplayNameCompositePriceFilter FromRawUnchecked( + public GroupedWithMinMaxThresholdsCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => MatrixWithDisplayNameCompositePriceFilter.FromRawUnchecked(rawData); + ) => GroupedWithMinMaxThresholdsCompositePriceFilter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(MatrixWithDisplayNameCompositePriceFilterFieldConverter))] -public enum MatrixWithDisplayNameCompositePriceFilterField +[JsonConverter(typeof(GroupedWithMinMaxThresholdsCompositePriceFilterFieldConverter))] +public enum GroupedWithMinMaxThresholdsCompositePriceFilterField { PriceID, ItemID, @@ -28464,10 +27199,10 @@ public enum MatrixWithDisplayNameCompositePriceFilterField PricingUnitID, } -sealed class MatrixWithDisplayNameCompositePriceFilterFieldConverter - : JsonConverter +sealed class GroupedWithMinMaxThresholdsCompositePriceFilterFieldConverter + : JsonConverter { - public override MatrixWithDisplayNameCompositePriceFilterField Read( + public override GroupedWithMinMaxThresholdsCompositePriceFilterField Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -28475,18 +27210,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "price_id" => MatrixWithDisplayNameCompositePriceFilterField.PriceID, - "item_id" => MatrixWithDisplayNameCompositePriceFilterField.ItemID, - "price_type" => MatrixWithDisplayNameCompositePriceFilterField.PriceType, - "currency" => MatrixWithDisplayNameCompositePriceFilterField.Currency, - "pricing_unit_id" => MatrixWithDisplayNameCompositePriceFilterField.PricingUnitID, - _ => (MatrixWithDisplayNameCompositePriceFilterField)(-1), + "price_id" => GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, + "item_id" => GroupedWithMinMaxThresholdsCompositePriceFilterField.ItemID, + "price_type" => GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceType, + "currency" => GroupedWithMinMaxThresholdsCompositePriceFilterField.Currency, + "pricing_unit_id" => GroupedWithMinMaxThresholdsCompositePriceFilterField.PricingUnitID, + _ => (GroupedWithMinMaxThresholdsCompositePriceFilterField)(-1), }; } public override void Write( Utf8JsonWriter writer, - MatrixWithDisplayNameCompositePriceFilterField value, + GroupedWithMinMaxThresholdsCompositePriceFilterField value, JsonSerializerOptions options ) { @@ -28494,11 +27229,12 @@ JsonSerializerOptions options writer, value switch { - MatrixWithDisplayNameCompositePriceFilterField.PriceID => "price_id", - MatrixWithDisplayNameCompositePriceFilterField.ItemID => "item_id", - MatrixWithDisplayNameCompositePriceFilterField.PriceType => "price_type", - MatrixWithDisplayNameCompositePriceFilterField.Currency => "currency", - MatrixWithDisplayNameCompositePriceFilterField.PricingUnitID => "pricing_unit_id", + GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID => "price_id", + GroupedWithMinMaxThresholdsCompositePriceFilterField.ItemID => "item_id", + GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceType => "price_type", + GroupedWithMinMaxThresholdsCompositePriceFilterField.Currency => "currency", + GroupedWithMinMaxThresholdsCompositePriceFilterField.PricingUnitID => + "pricing_unit_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -28511,17 +27247,17 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(MatrixWithDisplayNameCompositePriceFilterOperatorConverter))] -public enum MatrixWithDisplayNameCompositePriceFilterOperator +[JsonConverter(typeof(GroupedWithMinMaxThresholdsCompositePriceFilterOperatorConverter))] +public enum GroupedWithMinMaxThresholdsCompositePriceFilterOperator { Includes, Excludes, } -sealed class MatrixWithDisplayNameCompositePriceFilterOperatorConverter - : JsonConverter +sealed class GroupedWithMinMaxThresholdsCompositePriceFilterOperatorConverter + : JsonConverter { - public override MatrixWithDisplayNameCompositePriceFilterOperator Read( + public override GroupedWithMinMaxThresholdsCompositePriceFilterOperator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -28529,15 +27265,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => MatrixWithDisplayNameCompositePriceFilterOperator.Includes, - "excludes" => MatrixWithDisplayNameCompositePriceFilterOperator.Excludes, - _ => (MatrixWithDisplayNameCompositePriceFilterOperator)(-1), + "includes" => GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, + "excludes" => GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Excludes, + _ => (GroupedWithMinMaxThresholdsCompositePriceFilterOperator)(-1), }; } public override void Write( Utf8JsonWriter writer, - MatrixWithDisplayNameCompositePriceFilterOperator value, + GroupedWithMinMaxThresholdsCompositePriceFilterOperator value, JsonSerializerOptions options ) { @@ -28545,8 +27281,8 @@ JsonSerializerOptions options writer, value switch { - MatrixWithDisplayNameCompositePriceFilterOperator.Includes => "includes", - MatrixWithDisplayNameCompositePriceFilterOperator.Excludes => "excludes", + GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes => "includes", + GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -28556,8 +27292,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(MatrixWithDisplayNameConversionRateConfigConverter))] -public record class MatrixWithDisplayNameConversionRateConfig : ModelBase +[JsonConverter(typeof(GroupedWithMinMaxThresholdsConversionRateConfigConverter))] +public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -28574,7 +27310,7 @@ public JsonElement Json } } - public MatrixWithDisplayNameConversionRateConfig( + public GroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -28583,7 +27319,7 @@ public MatrixWithDisplayNameConversionRateConfig( this._element = element; } - public MatrixWithDisplayNameConversionRateConfig( + public GroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -28592,7 +27328,7 @@ public MatrixWithDisplayNameConversionRateConfig( this._element = element; } - public MatrixWithDisplayNameConversionRateConfig(JsonElement element) + public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -28674,7 +27410,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of MatrixWithDisplayNameConversionRateConfig" + "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" ); } } @@ -28710,16 +27446,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of MatrixWithDisplayNameConversionRateConfig" + "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" ), }; } - public static implicit operator MatrixWithDisplayNameConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator MatrixWithDisplayNameConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -28738,13 +27474,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of MatrixWithDisplayNameConversionRateConfig" + "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(MatrixWithDisplayNameConversionRateConfig? other) + public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -28758,10 +27494,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class MatrixWithDisplayNameConversionRateConfigConverter - : JsonConverter +sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter { - public override MatrixWithDisplayNameConversionRateConfig? Read( + public override GroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -28826,14 +27562,14 @@ JsonSerializerOptions options } default: { - return new MatrixWithDisplayNameConversionRateConfig(element); + return new GroupedWithMinMaxThresholdsConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - MatrixWithDisplayNameConversionRateConfig value, + GroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -28842,183 +27578,99 @@ JsonSerializerOptions options } /// -/// Configuration for matrix_with_display_name pricing +/// Configuration for grouped_with_min_max_thresholds pricing /// [JsonConverter( typeof(JsonModelConverter< - MatrixWithDisplayNameMatrixWithDisplayNameConfig, - MatrixWithDisplayNameMatrixWithDisplayNameConfigFromRaw + GroupedWithMinMaxThresholdsConfig, + GroupedWithMinMaxThresholdsConfigFromRaw >) )] -public sealed record class MatrixWithDisplayNameMatrixWithDisplayNameConfig : JsonModel +public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel { /// - /// Used to determine the unit rate - /// - public required string Dimension - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("dimension"); - } - init { this._rawData.Set("dimension", value); } - } - - /// - /// Apply per unit pricing to each dimension value + /// The event property used to group before applying thresholds /// - public required IReadOnlyList UnitAmounts + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("unit_amounts"); - } - init - { - this._rawData.Set< - ImmutableArray - >("unit_amounts", ImmutableArray.ToImmutableArray(value)); - } - } - - /// - public override void Validate() - { - _ = this.Dimension; - foreach (var item in this.UnitAmounts) - { - item.Validate(); + return this._rawData.GetNotNullClass("grouping_key"); } + init { this._rawData.Set("grouping_key", value); } } - public MatrixWithDisplayNameMatrixWithDisplayNameConfig() { } - - public MatrixWithDisplayNameMatrixWithDisplayNameConfig( - MatrixWithDisplayNameMatrixWithDisplayNameConfig matrixWithDisplayNameMatrixWithDisplayNameConfig - ) - : base(matrixWithDisplayNameMatrixWithDisplayNameConfig) { } - - public MatrixWithDisplayNameMatrixWithDisplayNameConfig( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - MatrixWithDisplayNameMatrixWithDisplayNameConfig(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static MatrixWithDisplayNameMatrixWithDisplayNameConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class MatrixWithDisplayNameMatrixWithDisplayNameConfigFromRaw - : IFromRawJson -{ - /// - public MatrixWithDisplayNameMatrixWithDisplayNameConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => MatrixWithDisplayNameMatrixWithDisplayNameConfig.FromRawUnchecked(rawData); -} - -/// -/// Configuration for a unit amount item -/// -[JsonConverter( - typeof(JsonModelConverter< - MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount, - MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmountFromRaw - >) -)] -public sealed record class MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount : JsonModel -{ /// - /// The dimension value + /// The maximum amount to charge each group /// - public required string DimensionValue + public required string MaximumCharge { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("dimension_value"); + return this._rawData.GetNotNullClass("maximum_charge"); } - init { this._rawData.Set("dimension_value", value); } + init { this._rawData.Set("maximum_charge", value); } } /// - /// Display name for this dimension value + /// The minimum amount to charge each group, regardless of usage /// - public required string DisplayName + public required string MinimumCharge { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("display_name"); + return this._rawData.GetNotNullClass("minimum_charge"); } - init { this._rawData.Set("display_name", value); } + init { this._rawData.Set("minimum_charge", value); } } /// - /// Per unit amount + /// The base price charged per group /// - public required string UnitAmount + public required string PerUnitRate { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullClass("per_unit_rate"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("per_unit_rate", value); } } /// public override void Validate() { - _ = this.DimensionValue; - _ = this.DisplayName; - _ = this.UnitAmount; + _ = this.GroupingKey; + _ = this.MaximumCharge; + _ = this.MinimumCharge; + _ = this.PerUnitRate; } - public MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount() { } + public GroupedWithMinMaxThresholdsConfig() { } - public MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount( - MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount matrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + public GroupedWithMinMaxThresholdsConfig( + GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) - : base(matrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount) { } + : base(groupedWithMinMaxThresholdsConfig) { } - public MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount( - IReadOnlyDictionary rawData - ) + public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount( - FrozenDictionary rawData - ) + GroupedWithMinMaxThresholdsConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -29026,26 +27678,26 @@ IReadOnlyDictionary rawData } } -class MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmountFromRaw - : IFromRawJson +class GroupedWithMinMaxThresholdsConfigFromRaw : IFromRawJson { /// - public MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount FromRawUnchecked( + public GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount.FromRawUnchecked(rawData); + ) => GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(MatrixWithDisplayNamePriceTypeConverter))] -public enum MatrixWithDisplayNamePriceType +[JsonConverter(typeof(GroupedWithMinMaxThresholdsPriceTypeConverter))] +public enum GroupedWithMinMaxThresholdsPriceType { UsagePrice, FixedPrice, CompositePrice, } -sealed class MatrixWithDisplayNamePriceTypeConverter : JsonConverter +sealed class GroupedWithMinMaxThresholdsPriceTypeConverter + : JsonConverter { - public override MatrixWithDisplayNamePriceType Read( + public override GroupedWithMinMaxThresholdsPriceType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -29053,16 +27705,16 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "usage_price" => MatrixWithDisplayNamePriceType.UsagePrice, - "fixed_price" => MatrixWithDisplayNamePriceType.FixedPrice, - "composite_price" => MatrixWithDisplayNamePriceType.CompositePrice, - _ => (MatrixWithDisplayNamePriceType)(-1), + "usage_price" => GroupedWithMinMaxThresholdsPriceType.UsagePrice, + "fixed_price" => GroupedWithMinMaxThresholdsPriceType.FixedPrice, + "composite_price" => GroupedWithMinMaxThresholdsPriceType.CompositePrice, + _ => (GroupedWithMinMaxThresholdsPriceType)(-1), }; } public override void Write( Utf8JsonWriter writer, - MatrixWithDisplayNamePriceType value, + GroupedWithMinMaxThresholdsPriceType value, JsonSerializerOptions options ) { @@ -29070,9 +27722,9 @@ JsonSerializerOptions options writer, value switch { - MatrixWithDisplayNamePriceType.UsagePrice => "usage_price", - MatrixWithDisplayNamePriceType.FixedPrice => "fixed_price", - MatrixWithDisplayNamePriceType.CompositePrice => "composite_price", + GroupedWithMinMaxThresholdsPriceType.UsagePrice => "usage_price", + GroupedWithMinMaxThresholdsPriceType.FixedPrice => "fixed_price", + GroupedWithMinMaxThresholdsPriceType.CompositePrice => "composite_price", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -29082,8 +27734,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class GroupedTieredPackage : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MatrixWithDisplayName : JsonModel { public required string ID { @@ -29117,42 +27769,42 @@ public required BillingCycleConfiguration BillingCycleConfiguration init { this._rawData.Set("billing_cycle_configuration", value); } } - public required ApiEnum BillingMode + public required ApiEnum BillingMode { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( + return this._rawData.GetNotNullClass>( "billing_mode" ); } init { this._rawData.Set("billing_mode", value); } } - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( + return this._rawData.GetNotNullClass>( "cadence" ); } init { this._rawData.Set("cadence", value); } } - public required IReadOnlyList? CompositePriceFilters + public required IReadOnlyList? CompositePriceFilters { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("composite_price_filters"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "composite_price_filters", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -29169,12 +27821,12 @@ public required double? ConversionRate init { this._rawData.Set("conversion_rate", value); } } - public required GroupedTieredPackageConversionRateConfig? ConversionRateConfig + public required MatrixWithDisplayNameConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -29242,21 +27894,6 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } - /// - /// Configuration for grouped_tiered_package pricing - /// - public required GroupedTieredPackageGroupedTieredPackageConfig GroupedTieredPackageConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_tiered_package_config" - ); - } - init { this._rawData.Set("grouped_tiered_package_config", value); } - } - public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -29282,6 +27919,21 @@ public required ItemSlim Item init { this._rawData.Set("item", value); } } + /// + /// Configuration for matrix_with_display_name pricing + /// + public required MatrixWithDisplayNameMatrixWithDisplayNameConfig MatrixWithDisplayNameConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "matrix_with_display_name_config" + ); + } + init { this._rawData.Set("matrix_with_display_name_config", value); } + } + [System::Obsolete("deprecated")] public required Maximum? Maximum { @@ -29381,12 +28033,12 @@ public required long? PlanPhaseOrder init { this._rawData.Set("plan_phase_order", value); } } - public required ApiEnum PriceType + public required ApiEnum PriceType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( + return this._rawData.GetNotNullClass>( "price_type" ); } @@ -29439,9 +28091,9 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; - this.GroupedTieredPackageConfig.Validate(); this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); + this.MatrixWithDisplayNameConfig.Validate(); this.Maximum?.Validate(); _ = this.MaximumAmount; _ = this.Metadata; @@ -29450,7 +28102,7 @@ public override void Validate() if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("grouped_tiered_package") + JsonSerializer.SerializeToElement("matrix_with_display_name") ) ) { @@ -29466,25 +28118,25 @@ public override void Validate() [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public GroupedTieredPackage() + public MatrixWithDisplayName() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_display_name"); } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public GroupedTieredPackage(GroupedTieredPackage groupedTieredPackage) - : base(groupedTieredPackage) { } + public MatrixWithDisplayName(MatrixWithDisplayName matrixWithDisplayName) + : base(matrixWithDisplayName) { } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public GroupedTieredPackage(IReadOnlyDictionary rawData) + public MatrixWithDisplayName(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); + this.ModelType = JsonSerializer.SerializeToElement("matrix_with_display_name"); } #pragma warning disable CS8618 @@ -29492,14 +28144,14 @@ public GroupedTieredPackage(IReadOnlyDictionary rawData) "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] [SetsRequiredMembers] - GroupedTieredPackage(FrozenDictionary rawData) + MatrixWithDisplayName(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static GroupedTieredPackage FromRawUnchecked( + /// + public static MatrixWithDisplayName FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -29507,25 +28159,25 @@ IReadOnlyDictionary rawData } } -class GroupedTieredPackageFromRaw : IFromRawJson +class MatrixWithDisplayNameFromRaw : IFromRawJson { /// - public GroupedTieredPackage FromRawUnchecked( + public MatrixWithDisplayName FromRawUnchecked( IReadOnlyDictionary rawData - ) => GroupedTieredPackage.FromRawUnchecked(rawData); + ) => MatrixWithDisplayName.FromRawUnchecked(rawData); } -[JsonConverter(typeof(GroupedTieredPackageBillingModeConverter))] -public enum GroupedTieredPackageBillingMode +[JsonConverter(typeof(MatrixWithDisplayNameBillingModeConverter))] +public enum MatrixWithDisplayNameBillingMode { InAdvance, InArrear, } -sealed class GroupedTieredPackageBillingModeConverter - : JsonConverter +sealed class MatrixWithDisplayNameBillingModeConverter + : JsonConverter { - public override GroupedTieredPackageBillingMode Read( + public override MatrixWithDisplayNameBillingMode Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -29533,15 +28185,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "in_advance" => GroupedTieredPackageBillingMode.InAdvance, - "in_arrear" => GroupedTieredPackageBillingMode.InArrear, - _ => (GroupedTieredPackageBillingMode)(-1), + "in_advance" => MatrixWithDisplayNameBillingMode.InAdvance, + "in_arrear" => MatrixWithDisplayNameBillingMode.InArrear, + _ => (MatrixWithDisplayNameBillingMode)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedTieredPackageBillingMode value, + MatrixWithDisplayNameBillingMode value, JsonSerializerOptions options ) { @@ -29549,8 +28201,8 @@ JsonSerializerOptions options writer, value switch { - GroupedTieredPackageBillingMode.InAdvance => "in_advance", - GroupedTieredPackageBillingMode.InArrear => "in_arrear", + MatrixWithDisplayNameBillingMode.InAdvance => "in_advance", + MatrixWithDisplayNameBillingMode.InArrear => "in_arrear", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -29560,8 +28212,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(GroupedTieredPackageCadenceConverter))] -public enum GroupedTieredPackageCadence +[JsonConverter(typeof(MatrixWithDisplayNameCadenceConverter))] +public enum MatrixWithDisplayNameCadence { OneTime, Monthly, @@ -29571,9 +28223,9 @@ public enum GroupedTieredPackageCadence Custom, } -sealed class GroupedTieredPackageCadenceConverter : JsonConverter +sealed class MatrixWithDisplayNameCadenceConverter : JsonConverter { - public override GroupedTieredPackageCadence Read( + public override MatrixWithDisplayNameCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -29581,19 +28233,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "one_time" => GroupedTieredPackageCadence.OneTime, - "monthly" => GroupedTieredPackageCadence.Monthly, - "quarterly" => GroupedTieredPackageCadence.Quarterly, - "semi_annual" => GroupedTieredPackageCadence.SemiAnnual, - "annual" => GroupedTieredPackageCadence.Annual, - "custom" => GroupedTieredPackageCadence.Custom, - _ => (GroupedTieredPackageCadence)(-1), + "one_time" => MatrixWithDisplayNameCadence.OneTime, + "monthly" => MatrixWithDisplayNameCadence.Monthly, + "quarterly" => MatrixWithDisplayNameCadence.Quarterly, + "semi_annual" => MatrixWithDisplayNameCadence.SemiAnnual, + "annual" => MatrixWithDisplayNameCadence.Annual, + "custom" => MatrixWithDisplayNameCadence.Custom, + _ => (MatrixWithDisplayNameCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedTieredPackageCadence value, + MatrixWithDisplayNameCadence value, JsonSerializerOptions options ) { @@ -29601,12 +28253,12 @@ JsonSerializerOptions options writer, value switch { - GroupedTieredPackageCadence.OneTime => "one_time", - GroupedTieredPackageCadence.Monthly => "monthly", - GroupedTieredPackageCadence.Quarterly => "quarterly", - GroupedTieredPackageCadence.SemiAnnual => "semi_annual", - GroupedTieredPackageCadence.Annual => "annual", - GroupedTieredPackageCadence.Custom => "custom", + MatrixWithDisplayNameCadence.OneTime => "one_time", + MatrixWithDisplayNameCadence.Monthly => "monthly", + MatrixWithDisplayNameCadence.Quarterly => "quarterly", + MatrixWithDisplayNameCadence.SemiAnnual => "semi_annual", + MatrixWithDisplayNameCadence.Annual => "annual", + MatrixWithDisplayNameCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -29618,22 +28270,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - GroupedTieredPackageCompositePriceFilter, - GroupedTieredPackageCompositePriceFilterFromRaw + MatrixWithDisplayNameCompositePriceFilter, + MatrixWithDisplayNameCompositePriceFilterFromRaw >) )] -public sealed record class GroupedTieredPackageCompositePriceFilter : JsonModel +public sealed record class MatrixWithDisplayNameCompositePriceFilter : JsonModel { /// /// The property of the price to filter on. /// - public required ApiEnum Field + public required ApiEnum Field { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("field"); } init { this._rawData.Set("field", value); } @@ -29642,13 +28294,13 @@ public required ApiEnum F /// /// Should prices that match the filter be included or excluded. /// - public required ApiEnum Operator + public required ApiEnum Operator { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("operator"); } init { this._rawData.Set("operator", value); } @@ -29681,14 +28333,14 @@ public override void Validate() _ = this.Values; } - public GroupedTieredPackageCompositePriceFilter() { } + public MatrixWithDisplayNameCompositePriceFilter() { } - public GroupedTieredPackageCompositePriceFilter( - GroupedTieredPackageCompositePriceFilter groupedTieredPackageCompositePriceFilter + public MatrixWithDisplayNameCompositePriceFilter( + MatrixWithDisplayNameCompositePriceFilter matrixWithDisplayNameCompositePriceFilter ) - : base(groupedTieredPackageCompositePriceFilter) { } + : base(matrixWithDisplayNameCompositePriceFilter) { } - public GroupedTieredPackageCompositePriceFilter( + public MatrixWithDisplayNameCompositePriceFilter( IReadOnlyDictionary rawData ) { @@ -29697,14 +28349,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedTieredPackageCompositePriceFilter(FrozenDictionary rawData) + MatrixWithDisplayNameCompositePriceFilter(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static GroupedTieredPackageCompositePriceFilter FromRawUnchecked( + /// + public static MatrixWithDisplayNameCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -29712,20 +28364,20 @@ IReadOnlyDictionary rawData } } -class GroupedTieredPackageCompositePriceFilterFromRaw - : IFromRawJson +class MatrixWithDisplayNameCompositePriceFilterFromRaw + : IFromRawJson { /// - public GroupedTieredPackageCompositePriceFilter FromRawUnchecked( + public MatrixWithDisplayNameCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => GroupedTieredPackageCompositePriceFilter.FromRawUnchecked(rawData); + ) => MatrixWithDisplayNameCompositePriceFilter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(GroupedTieredPackageCompositePriceFilterFieldConverter))] -public enum GroupedTieredPackageCompositePriceFilterField +[JsonConverter(typeof(MatrixWithDisplayNameCompositePriceFilterFieldConverter))] +public enum MatrixWithDisplayNameCompositePriceFilterField { PriceID, ItemID, @@ -29734,10 +28386,10 @@ public enum GroupedTieredPackageCompositePriceFilterField PricingUnitID, } -sealed class GroupedTieredPackageCompositePriceFilterFieldConverter - : JsonConverter +sealed class MatrixWithDisplayNameCompositePriceFilterFieldConverter + : JsonConverter { - public override GroupedTieredPackageCompositePriceFilterField Read( + public override MatrixWithDisplayNameCompositePriceFilterField Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -29745,18 +28397,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "price_id" => GroupedTieredPackageCompositePriceFilterField.PriceID, - "item_id" => GroupedTieredPackageCompositePriceFilterField.ItemID, - "price_type" => GroupedTieredPackageCompositePriceFilterField.PriceType, - "currency" => GroupedTieredPackageCompositePriceFilterField.Currency, - "pricing_unit_id" => GroupedTieredPackageCompositePriceFilterField.PricingUnitID, - _ => (GroupedTieredPackageCompositePriceFilterField)(-1), + "price_id" => MatrixWithDisplayNameCompositePriceFilterField.PriceID, + "item_id" => MatrixWithDisplayNameCompositePriceFilterField.ItemID, + "price_type" => MatrixWithDisplayNameCompositePriceFilterField.PriceType, + "currency" => MatrixWithDisplayNameCompositePriceFilterField.Currency, + "pricing_unit_id" => MatrixWithDisplayNameCompositePriceFilterField.PricingUnitID, + _ => (MatrixWithDisplayNameCompositePriceFilterField)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedTieredPackageCompositePriceFilterField value, + MatrixWithDisplayNameCompositePriceFilterField value, JsonSerializerOptions options ) { @@ -29764,11 +28416,11 @@ JsonSerializerOptions options writer, value switch { - GroupedTieredPackageCompositePriceFilterField.PriceID => "price_id", - GroupedTieredPackageCompositePriceFilterField.ItemID => "item_id", - GroupedTieredPackageCompositePriceFilterField.PriceType => "price_type", - GroupedTieredPackageCompositePriceFilterField.Currency => "currency", - GroupedTieredPackageCompositePriceFilterField.PricingUnitID => "pricing_unit_id", + MatrixWithDisplayNameCompositePriceFilterField.PriceID => "price_id", + MatrixWithDisplayNameCompositePriceFilterField.ItemID => "item_id", + MatrixWithDisplayNameCompositePriceFilterField.PriceType => "price_type", + MatrixWithDisplayNameCompositePriceFilterField.Currency => "currency", + MatrixWithDisplayNameCompositePriceFilterField.PricingUnitID => "pricing_unit_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -29781,17 +28433,17 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(GroupedTieredPackageCompositePriceFilterOperatorConverter))] -public enum GroupedTieredPackageCompositePriceFilterOperator +[JsonConverter(typeof(MatrixWithDisplayNameCompositePriceFilterOperatorConverter))] +public enum MatrixWithDisplayNameCompositePriceFilterOperator { Includes, Excludes, } -sealed class GroupedTieredPackageCompositePriceFilterOperatorConverter - : JsonConverter +sealed class MatrixWithDisplayNameCompositePriceFilterOperatorConverter + : JsonConverter { - public override GroupedTieredPackageCompositePriceFilterOperator Read( + public override MatrixWithDisplayNameCompositePriceFilterOperator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -29799,15 +28451,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => GroupedTieredPackageCompositePriceFilterOperator.Includes, - "excludes" => GroupedTieredPackageCompositePriceFilterOperator.Excludes, - _ => (GroupedTieredPackageCompositePriceFilterOperator)(-1), + "includes" => MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + "excludes" => MatrixWithDisplayNameCompositePriceFilterOperator.Excludes, + _ => (MatrixWithDisplayNameCompositePriceFilterOperator)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedTieredPackageCompositePriceFilterOperator value, + MatrixWithDisplayNameCompositePriceFilterOperator value, JsonSerializerOptions options ) { @@ -29815,8 +28467,8 @@ JsonSerializerOptions options writer, value switch { - GroupedTieredPackageCompositePriceFilterOperator.Includes => "includes", - GroupedTieredPackageCompositePriceFilterOperator.Excludes => "excludes", + MatrixWithDisplayNameCompositePriceFilterOperator.Includes => "includes", + MatrixWithDisplayNameCompositePriceFilterOperator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -29826,8 +28478,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(GroupedTieredPackageConversionRateConfigConverter))] -public record class GroupedTieredPackageConversionRateConfig : ModelBase +[JsonConverter(typeof(MatrixWithDisplayNameConversionRateConfigConverter))] +public record class MatrixWithDisplayNameConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -29844,7 +28496,7 @@ public JsonElement Json } } - public GroupedTieredPackageConversionRateConfig( + public MatrixWithDisplayNameConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -29853,7 +28505,7 @@ public GroupedTieredPackageConversionRateConfig( this._element = element; } - public GroupedTieredPackageConversionRateConfig( + public MatrixWithDisplayNameConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -29862,7 +28514,7 @@ public GroupedTieredPackageConversionRateConfig( this._element = element; } - public GroupedTieredPackageConversionRateConfig(JsonElement element) + public MatrixWithDisplayNameConversionRateConfig(JsonElement element) { this._element = element; } @@ -29944,7 +28596,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of GroupedTieredPackageConversionRateConfig" + "Data did not match any variant of MatrixWithDisplayNameConversionRateConfig" ); } } @@ -29980,16 +28632,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of GroupedTieredPackageConversionRateConfig" + "Data did not match any variant of MatrixWithDisplayNameConversionRateConfig" ), }; } - public static implicit operator GroupedTieredPackageConversionRateConfig( + public static implicit operator MatrixWithDisplayNameConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator GroupedTieredPackageConversionRateConfig( + public static implicit operator MatrixWithDisplayNameConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -30008,13 +28660,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of GroupedTieredPackageConversionRateConfig" + "Data did not match any variant of MatrixWithDisplayNameConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(GroupedTieredPackageConversionRateConfig? other) + public virtual bool Equals(MatrixWithDisplayNameConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -30028,10 +28680,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class GroupedTieredPackageConversionRateConfigConverter - : JsonConverter +sealed class MatrixWithDisplayNameConversionRateConfigConverter + : JsonConverter { - public override GroupedTieredPackageConversionRateConfig? Read( + public override MatrixWithDisplayNameConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -30096,14 +28748,14 @@ JsonSerializerOptions options } default: { - return new GroupedTieredPackageConversionRateConfig(element); + return new MatrixWithDisplayNameConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - GroupedTieredPackageConversionRateConfig value, + MatrixWithDisplayNameConversionRateConfig value, JsonSerializerOptions options ) { @@ -30112,80 +28764,67 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_tiered_package pricing +/// Configuration for matrix_with_display_name pricing /// [JsonConverter( typeof(JsonModelConverter< - GroupedTieredPackageGroupedTieredPackageConfig, - GroupedTieredPackageGroupedTieredPackageConfigFromRaw + MatrixWithDisplayNameMatrixWithDisplayNameConfig, + MatrixWithDisplayNameMatrixWithDisplayNameConfigFromRaw >) )] -public sealed record class GroupedTieredPackageGroupedTieredPackageConfig : JsonModel +public sealed record class MatrixWithDisplayNameMatrixWithDisplayNameConfig : JsonModel { /// - /// The event property used to group before tiering + /// Used to determine the unit rate /// - public required string GroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); - } - init { this._rawData.Set("grouping_key", value); } - } - - public required string PackageSize + public required string Dimension { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("package_size"); + return this._rawData.GetNotNullClass("dimension"); } - init { this._rawData.Set("package_size", value); } + init { this._rawData.Set("dimension", value); } } /// - /// Apply tiered pricing after rounding up the quantity to the package size. - /// Tiers are defined using exclusive lower bounds. + /// Apply per unit pricing to each dimension value /// - public required IReadOnlyList Tiers + public required IReadOnlyList UnitAmounts { get { this._rawData.Freeze(); return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + ImmutableArray + >("unit_amounts"); } init { - this._rawData.Set>( - "tiers", - ImmutableArray.ToImmutableArray(value) - ); + this._rawData.Set< + ImmutableArray + >("unit_amounts", ImmutableArray.ToImmutableArray(value)); } } /// public override void Validate() { - _ = this.GroupingKey; - _ = this.PackageSize; - foreach (var item in this.Tiers) + _ = this.Dimension; + foreach (var item in this.UnitAmounts) { item.Validate(); } } - public GroupedTieredPackageGroupedTieredPackageConfig() { } + public MatrixWithDisplayNameMatrixWithDisplayNameConfig() { } - public GroupedTieredPackageGroupedTieredPackageConfig( - GroupedTieredPackageGroupedTieredPackageConfig groupedTieredPackageGroupedTieredPackageConfig + public MatrixWithDisplayNameMatrixWithDisplayNameConfig( + MatrixWithDisplayNameMatrixWithDisplayNameConfig matrixWithDisplayNameMatrixWithDisplayNameConfig ) - : base(groupedTieredPackageGroupedTieredPackageConfig) { } + : base(matrixWithDisplayNameMatrixWithDisplayNameConfig) { } - public GroupedTieredPackageGroupedTieredPackageConfig( + public MatrixWithDisplayNameMatrixWithDisplayNameConfig( IReadOnlyDictionary rawData ) { @@ -30194,14 +28833,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedTieredPackageGroupedTieredPackageConfig(FrozenDictionary rawData) + MatrixWithDisplayNameMatrixWithDisplayNameConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static GroupedTieredPackageGroupedTieredPackageConfig FromRawUnchecked( + /// + public static MatrixWithDisplayNameMatrixWithDisplayNameConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -30209,64 +28848,81 @@ IReadOnlyDictionary rawData } } -class GroupedTieredPackageGroupedTieredPackageConfigFromRaw - : IFromRawJson +class MatrixWithDisplayNameMatrixWithDisplayNameConfigFromRaw + : IFromRawJson { /// - public GroupedTieredPackageGroupedTieredPackageConfig FromRawUnchecked( + public MatrixWithDisplayNameMatrixWithDisplayNameConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => GroupedTieredPackageGroupedTieredPackageConfig.FromRawUnchecked(rawData); + ) => MatrixWithDisplayNameMatrixWithDisplayNameConfig.FromRawUnchecked(rawData); } /// -/// Configuration for a single tier +/// Configuration for a unit amount item /// [JsonConverter( typeof(JsonModelConverter< - GroupedTieredPackageGroupedTieredPackageConfigTier, - GroupedTieredPackageGroupedTieredPackageConfigTierFromRaw + MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount, + MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmountFromRaw >) )] -public sealed record class GroupedTieredPackageGroupedTieredPackageConfigTier : JsonModel +public sealed record class MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount : JsonModel { /// - /// Per package + /// The dimension value /// - public required string PerUnit + public required string DimensionValue { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("per_unit"); + return this._rawData.GetNotNullClass("dimension_value"); } - init { this._rawData.Set("per_unit", value); } + init { this._rawData.Set("dimension_value", value); } } - public required string TierLowerBound + /// + /// Display name for this dimension value + /// + public required string DisplayName { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("display_name"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("display_name", value); } + } + + /// + /// Per unit amount + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.PerUnit; - _ = this.TierLowerBound; + _ = this.DimensionValue; + _ = this.DisplayName; + _ = this.UnitAmount; } - public GroupedTieredPackageGroupedTieredPackageConfigTier() { } + public MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount() { } - public GroupedTieredPackageGroupedTieredPackageConfigTier( - GroupedTieredPackageGroupedTieredPackageConfigTier groupedTieredPackageGroupedTieredPackageConfigTier + public MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount( + MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount matrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount ) - : base(groupedTieredPackageGroupedTieredPackageConfigTier) { } + : base(matrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount) { } - public GroupedTieredPackageGroupedTieredPackageConfigTier( + public MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount( IReadOnlyDictionary rawData ) { @@ -30275,7 +28931,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedTieredPackageGroupedTieredPackageConfigTier( + MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount( FrozenDictionary rawData ) { @@ -30283,8 +28939,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static GroupedTieredPackageGroupedTieredPackageConfigTier FromRawUnchecked( + /// + public static MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -30292,26 +28948,26 @@ IReadOnlyDictionary rawData } } -class GroupedTieredPackageGroupedTieredPackageConfigTierFromRaw - : IFromRawJson +class MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmountFromRaw + : IFromRawJson { /// - public GroupedTieredPackageGroupedTieredPackageConfigTier FromRawUnchecked( + public MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount FromRawUnchecked( IReadOnlyDictionary rawData - ) => GroupedTieredPackageGroupedTieredPackageConfigTier.FromRawUnchecked(rawData); + ) => MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount.FromRawUnchecked(rawData); } -[JsonConverter(typeof(GroupedTieredPackagePriceTypeConverter))] -public enum GroupedTieredPackagePriceType +[JsonConverter(typeof(MatrixWithDisplayNamePriceTypeConverter))] +public enum MatrixWithDisplayNamePriceType { UsagePrice, FixedPrice, CompositePrice, } -sealed class GroupedTieredPackagePriceTypeConverter : JsonConverter +sealed class MatrixWithDisplayNamePriceTypeConverter : JsonConverter { - public override GroupedTieredPackagePriceType Read( + public override MatrixWithDisplayNamePriceType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -30319,16 +28975,16 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "usage_price" => GroupedTieredPackagePriceType.UsagePrice, - "fixed_price" => GroupedTieredPackagePriceType.FixedPrice, - "composite_price" => GroupedTieredPackagePriceType.CompositePrice, - _ => (GroupedTieredPackagePriceType)(-1), + "usage_price" => MatrixWithDisplayNamePriceType.UsagePrice, + "fixed_price" => MatrixWithDisplayNamePriceType.FixedPrice, + "composite_price" => MatrixWithDisplayNamePriceType.CompositePrice, + _ => (MatrixWithDisplayNamePriceType)(-1), }; } public override void Write( Utf8JsonWriter writer, - GroupedTieredPackagePriceType value, + MatrixWithDisplayNamePriceType value, JsonSerializerOptions options ) { @@ -30336,9 +28992,9 @@ JsonSerializerOptions options writer, value switch { - GroupedTieredPackagePriceType.UsagePrice => "usage_price", - GroupedTieredPackagePriceType.FixedPrice => "fixed_price", - GroupedTieredPackagePriceType.CompositePrice => "composite_price", + MatrixWithDisplayNamePriceType.UsagePrice => "usage_price", + MatrixWithDisplayNamePriceType.FixedPrice => "fixed_price", + MatrixWithDisplayNamePriceType.CompositePrice => "composite_price", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -30348,8 +29004,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class MaxGroupTieredPackage : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class GroupedTieredPackage : JsonModel { public required string ID { @@ -30383,42 +29039,42 @@ public required BillingCycleConfiguration BillingCycleConfiguration init { this._rawData.Set("billing_cycle_configuration", value); } } - public required ApiEnum BillingMode + public required ApiEnum BillingMode { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( + return this._rawData.GetNotNullClass>( "billing_mode" ); } init { this._rawData.Set("billing_mode", value); } } - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( + return this._rawData.GetNotNullClass>( "cadence" ); } init { this._rawData.Set("cadence", value); } } - public required IReadOnlyList? CompositePriceFilters + public required IReadOnlyList? CompositePriceFilters { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("composite_price_filters"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "composite_price_filters", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -30435,12 +29091,12 @@ public required double? ConversionRate init { this._rawData.Set("conversion_rate", value); } } - public required MaxGroupTieredPackageConversionRateConfig? ConversionRateConfig + public required GroupedTieredPackageConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -30508,6 +29164,21 @@ public required double? FixedPriceQuantity init { this._rawData.Set("fixed_price_quantity", value); } } + /// + /// Configuration for grouped_tiered_package pricing + /// + public required GroupedTieredPackageGroupedTieredPackageConfig GroupedTieredPackageConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_tiered_package_config" + ); + } + init { this._rawData.Set("grouped_tiered_package_config", value); } + } + public required BillingCycleConfiguration? InvoicingCycleConfiguration { get @@ -30533,21 +29204,6 @@ public required ItemSlim Item init { this._rawData.Set("item", value); } } - /// - /// Configuration for max_group_tiered_package pricing - /// - public required MaxGroupTieredPackageMaxGroupTieredPackageConfig MaxGroupTieredPackageConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "max_group_tiered_package_config" - ); - } - init { this._rawData.Set("max_group_tiered_package_config", value); } - } - [System::Obsolete("deprecated")] public required Maximum? Maximum { @@ -30647,12 +29303,12 @@ public required long? PlanPhaseOrder init { this._rawData.Set("plan_phase_order", value); } } - public required ApiEnum PriceType + public required ApiEnum PriceType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( + return this._rawData.GetNotNullClass>( "price_type" ); } @@ -30705,9 +29361,9 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + this.GroupedTieredPackageConfig.Validate(); this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); - this.MaxGroupTieredPackageConfig.Validate(); this.Maximum?.Validate(); _ = this.MaximumAmount; _ = this.Metadata; @@ -30716,7 +29372,7 @@ public override void Validate() if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("max_group_tiered_package") + JsonSerializer.SerializeToElement("grouped_tiered_package") ) ) { @@ -30732,25 +29388,25 @@ public override void Validate() [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public MaxGroupTieredPackage() + public GroupedTieredPackage() { - this.ModelType = JsonSerializer.SerializeToElement("max_group_tiered_package"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public MaxGroupTieredPackage(MaxGroupTieredPackage maxGroupTieredPackage) - : base(maxGroupTieredPackage) { } + public GroupedTieredPackage(GroupedTieredPackage groupedTieredPackage) + : base(groupedTieredPackage) { } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public MaxGroupTieredPackage(IReadOnlyDictionary rawData) + public GroupedTieredPackage(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("max_group_tiered_package"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); } #pragma warning disable CS8618 @@ -30758,14 +29414,14 @@ public MaxGroupTieredPackage(IReadOnlyDictionary rawData) "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] [SetsRequiredMembers] - MaxGroupTieredPackage(FrozenDictionary rawData) + GroupedTieredPackage(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static MaxGroupTieredPackage FromRawUnchecked( + /// + public static GroupedTieredPackage FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -30773,25 +29429,25 @@ IReadOnlyDictionary rawData } } -class MaxGroupTieredPackageFromRaw : IFromRawJson +class GroupedTieredPackageFromRaw : IFromRawJson { /// - public MaxGroupTieredPackage FromRawUnchecked( + public GroupedTieredPackage FromRawUnchecked( IReadOnlyDictionary rawData - ) => MaxGroupTieredPackage.FromRawUnchecked(rawData); + ) => GroupedTieredPackage.FromRawUnchecked(rawData); } -[JsonConverter(typeof(MaxGroupTieredPackageBillingModeConverter))] -public enum MaxGroupTieredPackageBillingMode +[JsonConverter(typeof(GroupedTieredPackageBillingModeConverter))] +public enum GroupedTieredPackageBillingMode { InAdvance, InArrear, } -sealed class MaxGroupTieredPackageBillingModeConverter - : JsonConverter +sealed class GroupedTieredPackageBillingModeConverter + : JsonConverter { - public override MaxGroupTieredPackageBillingMode Read( + public override GroupedTieredPackageBillingMode Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -30799,15 +29455,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "in_advance" => MaxGroupTieredPackageBillingMode.InAdvance, - "in_arrear" => MaxGroupTieredPackageBillingMode.InArrear, - _ => (MaxGroupTieredPackageBillingMode)(-1), + "in_advance" => GroupedTieredPackageBillingMode.InAdvance, + "in_arrear" => GroupedTieredPackageBillingMode.InArrear, + _ => (GroupedTieredPackageBillingMode)(-1), }; } public override void Write( Utf8JsonWriter writer, - MaxGroupTieredPackageBillingMode value, + GroupedTieredPackageBillingMode value, JsonSerializerOptions options ) { @@ -30815,8 +29471,8 @@ JsonSerializerOptions options writer, value switch { - MaxGroupTieredPackageBillingMode.InAdvance => "in_advance", - MaxGroupTieredPackageBillingMode.InArrear => "in_arrear", + GroupedTieredPackageBillingMode.InAdvance => "in_advance", + GroupedTieredPackageBillingMode.InArrear => "in_arrear", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -30826,8 +29482,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(MaxGroupTieredPackageCadenceConverter))] -public enum MaxGroupTieredPackageCadence +[JsonConverter(typeof(GroupedTieredPackageCadenceConverter))] +public enum GroupedTieredPackageCadence { OneTime, Monthly, @@ -30837,9 +29493,9 @@ public enum MaxGroupTieredPackageCadence Custom, } -sealed class MaxGroupTieredPackageCadenceConverter : JsonConverter +sealed class GroupedTieredPackageCadenceConverter : JsonConverter { - public override MaxGroupTieredPackageCadence Read( + public override GroupedTieredPackageCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -30847,19 +29503,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "one_time" => MaxGroupTieredPackageCadence.OneTime, - "monthly" => MaxGroupTieredPackageCadence.Monthly, - "quarterly" => MaxGroupTieredPackageCadence.Quarterly, - "semi_annual" => MaxGroupTieredPackageCadence.SemiAnnual, - "annual" => MaxGroupTieredPackageCadence.Annual, - "custom" => MaxGroupTieredPackageCadence.Custom, - _ => (MaxGroupTieredPackageCadence)(-1), + "one_time" => GroupedTieredPackageCadence.OneTime, + "monthly" => GroupedTieredPackageCadence.Monthly, + "quarterly" => GroupedTieredPackageCadence.Quarterly, + "semi_annual" => GroupedTieredPackageCadence.SemiAnnual, + "annual" => GroupedTieredPackageCadence.Annual, + "custom" => GroupedTieredPackageCadence.Custom, + _ => (GroupedTieredPackageCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - MaxGroupTieredPackageCadence value, + GroupedTieredPackageCadence value, JsonSerializerOptions options ) { @@ -30867,12 +29523,12 @@ JsonSerializerOptions options writer, value switch { - MaxGroupTieredPackageCadence.OneTime => "one_time", - MaxGroupTieredPackageCadence.Monthly => "monthly", - MaxGroupTieredPackageCadence.Quarterly => "quarterly", - MaxGroupTieredPackageCadence.SemiAnnual => "semi_annual", - MaxGroupTieredPackageCadence.Annual => "annual", - MaxGroupTieredPackageCadence.Custom => "custom", + GroupedTieredPackageCadence.OneTime => "one_time", + GroupedTieredPackageCadence.Monthly => "monthly", + GroupedTieredPackageCadence.Quarterly => "quarterly", + GroupedTieredPackageCadence.SemiAnnual => "semi_annual", + GroupedTieredPackageCadence.Annual => "annual", + GroupedTieredPackageCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -30884,22 +29540,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - MaxGroupTieredPackageCompositePriceFilter, - MaxGroupTieredPackageCompositePriceFilterFromRaw + GroupedTieredPackageCompositePriceFilter, + GroupedTieredPackageCompositePriceFilterFromRaw >) )] -public sealed record class MaxGroupTieredPackageCompositePriceFilter : JsonModel +public sealed record class GroupedTieredPackageCompositePriceFilter : JsonModel { /// /// The property of the price to filter on. /// - public required ApiEnum Field + public required ApiEnum Field { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("field"); } init { this._rawData.Set("field", value); } @@ -30908,13 +29564,13 @@ public required ApiEnum /// /// Should prices that match the filter be included or excluded. /// - public required ApiEnum Operator + public required ApiEnum Operator { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("operator"); } init { this._rawData.Set("operator", value); } @@ -30947,14 +29603,14 @@ public override void Validate() _ = this.Values; } - public MaxGroupTieredPackageCompositePriceFilter() { } + public GroupedTieredPackageCompositePriceFilter() { } - public MaxGroupTieredPackageCompositePriceFilter( - MaxGroupTieredPackageCompositePriceFilter maxGroupTieredPackageCompositePriceFilter + public GroupedTieredPackageCompositePriceFilter( + GroupedTieredPackageCompositePriceFilter groupedTieredPackageCompositePriceFilter ) - : base(maxGroupTieredPackageCompositePriceFilter) { } + : base(groupedTieredPackageCompositePriceFilter) { } - public MaxGroupTieredPackageCompositePriceFilter( + public GroupedTieredPackageCompositePriceFilter( IReadOnlyDictionary rawData ) { @@ -30963,14 +29619,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - MaxGroupTieredPackageCompositePriceFilter(FrozenDictionary rawData) + GroupedTieredPackageCompositePriceFilter(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static MaxGroupTieredPackageCompositePriceFilter FromRawUnchecked( + /// + public static GroupedTieredPackageCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -30978,20 +29634,20 @@ IReadOnlyDictionary rawData } } -class MaxGroupTieredPackageCompositePriceFilterFromRaw - : IFromRawJson +class GroupedTieredPackageCompositePriceFilterFromRaw + : IFromRawJson { /// - public MaxGroupTieredPackageCompositePriceFilter FromRawUnchecked( + public GroupedTieredPackageCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => MaxGroupTieredPackageCompositePriceFilter.FromRawUnchecked(rawData); + ) => GroupedTieredPackageCompositePriceFilter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(MaxGroupTieredPackageCompositePriceFilterFieldConverter))] -public enum MaxGroupTieredPackageCompositePriceFilterField +[JsonConverter(typeof(GroupedTieredPackageCompositePriceFilterFieldConverter))] +public enum GroupedTieredPackageCompositePriceFilterField { PriceID, ItemID, @@ -31000,10 +29656,10 @@ public enum MaxGroupTieredPackageCompositePriceFilterField PricingUnitID, } -sealed class MaxGroupTieredPackageCompositePriceFilterFieldConverter - : JsonConverter +sealed class GroupedTieredPackageCompositePriceFilterFieldConverter + : JsonConverter { - public override MaxGroupTieredPackageCompositePriceFilterField Read( + public override GroupedTieredPackageCompositePriceFilterField Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -31011,18 +29667,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "price_id" => MaxGroupTieredPackageCompositePriceFilterField.PriceID, - "item_id" => MaxGroupTieredPackageCompositePriceFilterField.ItemID, - "price_type" => MaxGroupTieredPackageCompositePriceFilterField.PriceType, - "currency" => MaxGroupTieredPackageCompositePriceFilterField.Currency, - "pricing_unit_id" => MaxGroupTieredPackageCompositePriceFilterField.PricingUnitID, - _ => (MaxGroupTieredPackageCompositePriceFilterField)(-1), + "price_id" => GroupedTieredPackageCompositePriceFilterField.PriceID, + "item_id" => GroupedTieredPackageCompositePriceFilterField.ItemID, + "price_type" => GroupedTieredPackageCompositePriceFilterField.PriceType, + "currency" => GroupedTieredPackageCompositePriceFilterField.Currency, + "pricing_unit_id" => GroupedTieredPackageCompositePriceFilterField.PricingUnitID, + _ => (GroupedTieredPackageCompositePriceFilterField)(-1), }; } public override void Write( Utf8JsonWriter writer, - MaxGroupTieredPackageCompositePriceFilterField value, + GroupedTieredPackageCompositePriceFilterField value, JsonSerializerOptions options ) { @@ -31030,11 +29686,11 @@ JsonSerializerOptions options writer, value switch { - MaxGroupTieredPackageCompositePriceFilterField.PriceID => "price_id", - MaxGroupTieredPackageCompositePriceFilterField.ItemID => "item_id", - MaxGroupTieredPackageCompositePriceFilterField.PriceType => "price_type", - MaxGroupTieredPackageCompositePriceFilterField.Currency => "currency", - MaxGroupTieredPackageCompositePriceFilterField.PricingUnitID => "pricing_unit_id", + GroupedTieredPackageCompositePriceFilterField.PriceID => "price_id", + GroupedTieredPackageCompositePriceFilterField.ItemID => "item_id", + GroupedTieredPackageCompositePriceFilterField.PriceType => "price_type", + GroupedTieredPackageCompositePriceFilterField.Currency => "currency", + GroupedTieredPackageCompositePriceFilterField.PricingUnitID => "pricing_unit_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -31047,17 +29703,17 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(MaxGroupTieredPackageCompositePriceFilterOperatorConverter))] -public enum MaxGroupTieredPackageCompositePriceFilterOperator +[JsonConverter(typeof(GroupedTieredPackageCompositePriceFilterOperatorConverter))] +public enum GroupedTieredPackageCompositePriceFilterOperator { Includes, Excludes, } -sealed class MaxGroupTieredPackageCompositePriceFilterOperatorConverter - : JsonConverter +sealed class GroupedTieredPackageCompositePriceFilterOperatorConverter + : JsonConverter { - public override MaxGroupTieredPackageCompositePriceFilterOperator Read( + public override GroupedTieredPackageCompositePriceFilterOperator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -31065,15 +29721,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => MaxGroupTieredPackageCompositePriceFilterOperator.Includes, - "excludes" => MaxGroupTieredPackageCompositePriceFilterOperator.Excludes, - _ => (MaxGroupTieredPackageCompositePriceFilterOperator)(-1), + "includes" => GroupedTieredPackageCompositePriceFilterOperator.Includes, + "excludes" => GroupedTieredPackageCompositePriceFilterOperator.Excludes, + _ => (GroupedTieredPackageCompositePriceFilterOperator)(-1), }; } public override void Write( Utf8JsonWriter writer, - MaxGroupTieredPackageCompositePriceFilterOperator value, + GroupedTieredPackageCompositePriceFilterOperator value, JsonSerializerOptions options ) { @@ -31081,8 +29737,8 @@ JsonSerializerOptions options writer, value switch { - MaxGroupTieredPackageCompositePriceFilterOperator.Includes => "includes", - MaxGroupTieredPackageCompositePriceFilterOperator.Excludes => "excludes", + GroupedTieredPackageCompositePriceFilterOperator.Includes => "includes", + GroupedTieredPackageCompositePriceFilterOperator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -31092,8 +29748,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(MaxGroupTieredPackageConversionRateConfigConverter))] -public record class MaxGroupTieredPackageConversionRateConfig : ModelBase +[JsonConverter(typeof(GroupedTieredPackageConversionRateConfigConverter))] +public record class GroupedTieredPackageConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -31110,7 +29766,7 @@ public JsonElement Json } } - public MaxGroupTieredPackageConversionRateConfig( + public GroupedTieredPackageConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -31119,7 +29775,7 @@ public MaxGroupTieredPackageConversionRateConfig( this._element = element; } - public MaxGroupTieredPackageConversionRateConfig( + public GroupedTieredPackageConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -31128,7 +29784,7 @@ public MaxGroupTieredPackageConversionRateConfig( this._element = element; } - public MaxGroupTieredPackageConversionRateConfig(JsonElement element) + public GroupedTieredPackageConversionRateConfig(JsonElement element) { this._element = element; } @@ -31210,7 +29866,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of MaxGroupTieredPackageConversionRateConfig" + "Data did not match any variant of GroupedTieredPackageConversionRateConfig" ); } } @@ -31246,16 +29902,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of MaxGroupTieredPackageConversionRateConfig" + "Data did not match any variant of GroupedTieredPackageConversionRateConfig" ), }; } - public static implicit operator MaxGroupTieredPackageConversionRateConfig( + public static implicit operator GroupedTieredPackageConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator MaxGroupTieredPackageConversionRateConfig( + public static implicit operator GroupedTieredPackageConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -31274,13 +29930,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of MaxGroupTieredPackageConversionRateConfig" + "Data did not match any variant of GroupedTieredPackageConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(MaxGroupTieredPackageConversionRateConfig? other) + public virtual bool Equals(GroupedTieredPackageConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -31294,10 +29950,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class MaxGroupTieredPackageConversionRateConfigConverter - : JsonConverter +sealed class GroupedTieredPackageConversionRateConfigConverter + : JsonConverter { - public override MaxGroupTieredPackageConversionRateConfig? Read( + public override GroupedTieredPackageConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -31362,14 +30018,14 @@ JsonSerializerOptions options } default: { - return new MaxGroupTieredPackageConversionRateConfig(element); + return new GroupedTieredPackageConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - MaxGroupTieredPackageConversionRateConfig value, + GroupedTieredPackageConversionRateConfig value, JsonSerializerOptions options ) { @@ -31378,18 +30034,18 @@ JsonSerializerOptions options } /// -/// Configuration for max_group_tiered_package pricing +/// Configuration for grouped_tiered_package pricing /// [JsonConverter( typeof(JsonModelConverter< - MaxGroupTieredPackageMaxGroupTieredPackageConfig, - MaxGroupTieredPackageMaxGroupTieredPackageConfigFromRaw + GroupedTieredPackageGroupedTieredPackageConfig, + GroupedTieredPackageGroupedTieredPackageConfigFromRaw >) )] -public sealed record class MaxGroupTieredPackageMaxGroupTieredPackageConfig : JsonModel +public sealed record class GroupedTieredPackageGroupedTieredPackageConfig : JsonModel { /// - /// The event property used to group before tiering the group with the highest value + /// The event property used to group before tiering /// public required string GroupingKey { @@ -31412,20 +30068,21 @@ public required string PackageSize } /// - /// Apply tiered pricing to the largest group after grouping with the provided key. + /// Apply tiered pricing after rounding up the quantity to the package size. + /// Tiers are defined using exclusive lower bounds. /// - public required IReadOnlyList Tiers + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); return this._rawData.GetNotNullStruct< - ImmutableArray + ImmutableArray >("tiers"); } init { - this._rawData.Set>( + this._rawData.Set>( "tiers", ImmutableArray.ToImmutableArray(value) ); @@ -31443,14 +30100,14 @@ public override void Validate() } } - public MaxGroupTieredPackageMaxGroupTieredPackageConfig() { } + public GroupedTieredPackageGroupedTieredPackageConfig() { } - public MaxGroupTieredPackageMaxGroupTieredPackageConfig( - MaxGroupTieredPackageMaxGroupTieredPackageConfig maxGroupTieredPackageMaxGroupTieredPackageConfig + public GroupedTieredPackageGroupedTieredPackageConfig( + GroupedTieredPackageGroupedTieredPackageConfig groupedTieredPackageGroupedTieredPackageConfig ) - : base(maxGroupTieredPackageMaxGroupTieredPackageConfig) { } + : base(groupedTieredPackageGroupedTieredPackageConfig) { } - public MaxGroupTieredPackageMaxGroupTieredPackageConfig( + public GroupedTieredPackageGroupedTieredPackageConfig( IReadOnlyDictionary rawData ) { @@ -31459,14 +30116,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - MaxGroupTieredPackageMaxGroupTieredPackageConfig(FrozenDictionary rawData) + GroupedTieredPackageGroupedTieredPackageConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static MaxGroupTieredPackageMaxGroupTieredPackageConfig FromRawUnchecked( + /// + public static GroupedTieredPackageGroupedTieredPackageConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -31474,13 +30131,13 @@ IReadOnlyDictionary rawData } } -class MaxGroupTieredPackageMaxGroupTieredPackageConfigFromRaw - : IFromRawJson +class GroupedTieredPackageGroupedTieredPackageConfigFromRaw + : IFromRawJson { /// - public MaxGroupTieredPackageMaxGroupTieredPackageConfig FromRawUnchecked( + public GroupedTieredPackageGroupedTieredPackageConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => MaxGroupTieredPackageMaxGroupTieredPackageConfig.FromRawUnchecked(rawData); + ) => GroupedTieredPackageGroupedTieredPackageConfig.FromRawUnchecked(rawData); } /// @@ -31488,50 +30145,50 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - MaxGroupTieredPackageMaxGroupTieredPackageConfigTier, - MaxGroupTieredPackageMaxGroupTieredPackageConfigTierFromRaw + GroupedTieredPackageGroupedTieredPackageConfigTier, + GroupedTieredPackageGroupedTieredPackageConfigTierFromRaw >) )] -public sealed record class MaxGroupTieredPackageMaxGroupTieredPackageConfigTier : JsonModel +public sealed record class GroupedTieredPackageGroupedTieredPackageConfigTier : JsonModel { - public required string TierLowerBound + /// + /// Per package + /// + public required string PerUnit { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("per_unit"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("per_unit", value); } } - /// - /// Per unit amount - /// - public required string UnitAmount + public required string TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullClass("tier_lower_bound"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("tier_lower_bound", value); } } /// public override void Validate() { + _ = this.PerUnit; _ = this.TierLowerBound; - _ = this.UnitAmount; } - public MaxGroupTieredPackageMaxGroupTieredPackageConfigTier() { } + public GroupedTieredPackageGroupedTieredPackageConfigTier() { } - public MaxGroupTieredPackageMaxGroupTieredPackageConfigTier( - MaxGroupTieredPackageMaxGroupTieredPackageConfigTier maxGroupTieredPackageMaxGroupTieredPackageConfigTier + public GroupedTieredPackageGroupedTieredPackageConfigTier( + GroupedTieredPackageGroupedTieredPackageConfigTier groupedTieredPackageGroupedTieredPackageConfigTier ) - : base(maxGroupTieredPackageMaxGroupTieredPackageConfigTier) { } + : base(groupedTieredPackageGroupedTieredPackageConfigTier) { } - public MaxGroupTieredPackageMaxGroupTieredPackageConfigTier( + public GroupedTieredPackageGroupedTieredPackageConfigTier( IReadOnlyDictionary rawData ) { @@ -31540,7 +30197,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - MaxGroupTieredPackageMaxGroupTieredPackageConfigTier( + GroupedTieredPackageGroupedTieredPackageConfigTier( FrozenDictionary rawData ) { @@ -31548,8 +30205,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static MaxGroupTieredPackageMaxGroupTieredPackageConfigTier FromRawUnchecked( + /// + public static GroupedTieredPackageGroupedTieredPackageConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -31557,26 +30214,26 @@ IReadOnlyDictionary rawData } } -class MaxGroupTieredPackageMaxGroupTieredPackageConfigTierFromRaw - : IFromRawJson +class GroupedTieredPackageGroupedTieredPackageConfigTierFromRaw + : IFromRawJson { /// - public MaxGroupTieredPackageMaxGroupTieredPackageConfigTier FromRawUnchecked( + public GroupedTieredPackageGroupedTieredPackageConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => MaxGroupTieredPackageMaxGroupTieredPackageConfigTier.FromRawUnchecked(rawData); + ) => GroupedTieredPackageGroupedTieredPackageConfigTier.FromRawUnchecked(rawData); } -[JsonConverter(typeof(MaxGroupTieredPackagePriceTypeConverter))] -public enum MaxGroupTieredPackagePriceType +[JsonConverter(typeof(GroupedTieredPackagePriceTypeConverter))] +public enum GroupedTieredPackagePriceType { UsagePrice, FixedPrice, CompositePrice, } -sealed class MaxGroupTieredPackagePriceTypeConverter : JsonConverter +sealed class GroupedTieredPackagePriceTypeConverter : JsonConverter { - public override MaxGroupTieredPackagePriceType Read( + public override GroupedTieredPackagePriceType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -31584,16 +30241,16 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "usage_price" => MaxGroupTieredPackagePriceType.UsagePrice, - "fixed_price" => MaxGroupTieredPackagePriceType.FixedPrice, - "composite_price" => MaxGroupTieredPackagePriceType.CompositePrice, - _ => (MaxGroupTieredPackagePriceType)(-1), + "usage_price" => GroupedTieredPackagePriceType.UsagePrice, + "fixed_price" => GroupedTieredPackagePriceType.FixedPrice, + "composite_price" => GroupedTieredPackagePriceType.CompositePrice, + _ => (GroupedTieredPackagePriceType)(-1), }; } public override void Write( Utf8JsonWriter writer, - MaxGroupTieredPackagePriceType value, + GroupedTieredPackagePriceType value, JsonSerializerOptions options ) { @@ -31601,9 +30258,9 @@ JsonSerializerOptions options writer, value switch { - MaxGroupTieredPackagePriceType.UsagePrice => "usage_price", - MaxGroupTieredPackagePriceType.FixedPrice => "fixed_price", - MaxGroupTieredPackagePriceType.CompositePrice => "composite_price", + GroupedTieredPackagePriceType.UsagePrice => "usage_price", + GroupedTieredPackagePriceType.FixedPrice => "fixed_price", + GroupedTieredPackagePriceType.CompositePrice => "composite_price", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -31613,10 +30270,8 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter) -)] -public sealed record class ScalableMatrixWithUnitPricing : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MaxGroupTieredPackage : JsonModel { public required string ID { @@ -31650,42 +30305,42 @@ public required BillingCycleConfiguration BillingCycleConfiguration init { this._rawData.Set("billing_cycle_configuration", value); } } - public required ApiEnum BillingMode + public required ApiEnum BillingMode { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("billing_mode"); + return this._rawData.GetNotNullClass>( + "billing_mode" + ); } init { this._rawData.Set("billing_mode", value); } } - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } init { this._rawData.Set("cadence", value); } } - public required IReadOnlyList? CompositePriceFilters + public required IReadOnlyList? CompositePriceFilters { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("composite_price_filters"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "composite_price_filters", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -31702,12 +30357,12 @@ public required double? ConversionRate init { this._rawData.Set("conversion_rate", value); } } - public required ScalableMatrixWithUnitPricingConversionRateConfig? ConversionRateConfig + public required MaxGroupTieredPackageConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -31800,6 +30455,21 @@ public required ItemSlim Item init { this._rawData.Set("item", value); } } + /// + /// Configuration for max_group_tiered_package pricing + /// + public required MaxGroupTieredPackageMaxGroupTieredPackageConfig MaxGroupTieredPackageConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "max_group_tiered_package_config" + ); + } + init { this._rawData.Set("max_group_tiered_package_config", value); } + } + [System::Obsolete("deprecated")] public required Maximum? Maximum { @@ -31899,14 +30569,14 @@ public required long? PlanPhaseOrder init { this._rawData.Set("plan_phase_order", value); } } - public required ApiEnum PriceType + public required ApiEnum PriceType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("price_type"); + return this._rawData.GetNotNullClass>( + "price_type" + ); } init { this._rawData.Set("price_type", value); } } @@ -31925,21 +30595,6 @@ public required string? ReplacesPriceID init { this._rawData.Set("replaces_price_id", value); } } - /// - /// Configuration for scalable_matrix_with_unit_pricing pricing - /// - public required ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig ScalableMatrixWithUnitPricingConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "scalable_matrix_with_unit_pricing_config" - ); - } - init { this._rawData.Set("scalable_matrix_with_unit_pricing_config", value); } - } - public DimensionalPriceConfiguration? DimensionalPriceConfiguration { get @@ -31974,6 +30629,7 @@ public override void Validate() _ = this.FixedPriceQuantity; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); + this.MaxGroupTieredPackageConfig.Validate(); this.Maximum?.Validate(); _ = this.MaximumAmount; _ = this.Metadata; @@ -31982,7 +30638,7 @@ public override void Validate() if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing") + JsonSerializer.SerializeToElement("max_group_tiered_package") ) ) { @@ -31992,34 +30648,31 @@ public override void Validate() _ = this.PlanPhaseOrder; this.PriceType.Validate(); _ = this.ReplacesPriceID; - this.ScalableMatrixWithUnitPricingConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public ScalableMatrixWithUnitPricing() + public MaxGroupTieredPackage() { - this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing"); + this.ModelType = JsonSerializer.SerializeToElement("max_group_tiered_package"); } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public ScalableMatrixWithUnitPricing( - ScalableMatrixWithUnitPricing scalableMatrixWithUnitPricing - ) - : base(scalableMatrixWithUnitPricing) { } + public MaxGroupTieredPackage(MaxGroupTieredPackage maxGroupTieredPackage) + : base(maxGroupTieredPackage) { } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public ScalableMatrixWithUnitPricing(IReadOnlyDictionary rawData) + public MaxGroupTieredPackage(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing"); + this.ModelType = JsonSerializer.SerializeToElement("max_group_tiered_package"); } #pragma warning disable CS8618 @@ -32027,14 +30680,14 @@ public ScalableMatrixWithUnitPricing(IReadOnlyDictionary ra "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] [SetsRequiredMembers] - ScalableMatrixWithUnitPricing(FrozenDictionary rawData) + MaxGroupTieredPackage(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ScalableMatrixWithUnitPricing FromRawUnchecked( + /// + public static MaxGroupTieredPackage FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -32042,25 +30695,25 @@ IReadOnlyDictionary rawData } } -class ScalableMatrixWithUnitPricingFromRaw : IFromRawJson +class MaxGroupTieredPackageFromRaw : IFromRawJson { /// - public ScalableMatrixWithUnitPricing FromRawUnchecked( + public MaxGroupTieredPackage FromRawUnchecked( IReadOnlyDictionary rawData - ) => ScalableMatrixWithUnitPricing.FromRawUnchecked(rawData); + ) => MaxGroupTieredPackage.FromRawUnchecked(rawData); } -[JsonConverter(typeof(ScalableMatrixWithUnitPricingBillingModeConverter))] -public enum ScalableMatrixWithUnitPricingBillingMode +[JsonConverter(typeof(MaxGroupTieredPackageBillingModeConverter))] +public enum MaxGroupTieredPackageBillingMode { InAdvance, InArrear, } -sealed class ScalableMatrixWithUnitPricingBillingModeConverter - : JsonConverter +sealed class MaxGroupTieredPackageBillingModeConverter + : JsonConverter { - public override ScalableMatrixWithUnitPricingBillingMode Read( + public override MaxGroupTieredPackageBillingMode Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -32068,15 +30721,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "in_advance" => ScalableMatrixWithUnitPricingBillingMode.InAdvance, - "in_arrear" => ScalableMatrixWithUnitPricingBillingMode.InArrear, - _ => (ScalableMatrixWithUnitPricingBillingMode)(-1), + "in_advance" => MaxGroupTieredPackageBillingMode.InAdvance, + "in_arrear" => MaxGroupTieredPackageBillingMode.InArrear, + _ => (MaxGroupTieredPackageBillingMode)(-1), }; } public override void Write( Utf8JsonWriter writer, - ScalableMatrixWithUnitPricingBillingMode value, + MaxGroupTieredPackageBillingMode value, JsonSerializerOptions options ) { @@ -32084,8 +30737,8 @@ JsonSerializerOptions options writer, value switch { - ScalableMatrixWithUnitPricingBillingMode.InAdvance => "in_advance", - ScalableMatrixWithUnitPricingBillingMode.InArrear => "in_arrear", + MaxGroupTieredPackageBillingMode.InAdvance => "in_advance", + MaxGroupTieredPackageBillingMode.InArrear => "in_arrear", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -32095,8 +30748,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(ScalableMatrixWithUnitPricingCadenceConverter))] -public enum ScalableMatrixWithUnitPricingCadence +[JsonConverter(typeof(MaxGroupTieredPackageCadenceConverter))] +public enum MaxGroupTieredPackageCadence { OneTime, Monthly, @@ -32106,10 +30759,9 @@ public enum ScalableMatrixWithUnitPricingCadence Custom, } -sealed class ScalableMatrixWithUnitPricingCadenceConverter - : JsonConverter +sealed class MaxGroupTieredPackageCadenceConverter : JsonConverter { - public override ScalableMatrixWithUnitPricingCadence Read( + public override MaxGroupTieredPackageCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -32117,19 +30769,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "one_time" => ScalableMatrixWithUnitPricingCadence.OneTime, - "monthly" => ScalableMatrixWithUnitPricingCadence.Monthly, - "quarterly" => ScalableMatrixWithUnitPricingCadence.Quarterly, - "semi_annual" => ScalableMatrixWithUnitPricingCadence.SemiAnnual, - "annual" => ScalableMatrixWithUnitPricingCadence.Annual, - "custom" => ScalableMatrixWithUnitPricingCadence.Custom, - _ => (ScalableMatrixWithUnitPricingCadence)(-1), + "one_time" => MaxGroupTieredPackageCadence.OneTime, + "monthly" => MaxGroupTieredPackageCadence.Monthly, + "quarterly" => MaxGroupTieredPackageCadence.Quarterly, + "semi_annual" => MaxGroupTieredPackageCadence.SemiAnnual, + "annual" => MaxGroupTieredPackageCadence.Annual, + "custom" => MaxGroupTieredPackageCadence.Custom, + _ => (MaxGroupTieredPackageCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - ScalableMatrixWithUnitPricingCadence value, + MaxGroupTieredPackageCadence value, JsonSerializerOptions options ) { @@ -32137,12 +30789,12 @@ JsonSerializerOptions options writer, value switch { - ScalableMatrixWithUnitPricingCadence.OneTime => "one_time", - ScalableMatrixWithUnitPricingCadence.Monthly => "monthly", - ScalableMatrixWithUnitPricingCadence.Quarterly => "quarterly", - ScalableMatrixWithUnitPricingCadence.SemiAnnual => "semi_annual", - ScalableMatrixWithUnitPricingCadence.Annual => "annual", - ScalableMatrixWithUnitPricingCadence.Custom => "custom", + MaxGroupTieredPackageCadence.OneTime => "one_time", + MaxGroupTieredPackageCadence.Monthly => "monthly", + MaxGroupTieredPackageCadence.Quarterly => "quarterly", + MaxGroupTieredPackageCadence.SemiAnnual => "semi_annual", + MaxGroupTieredPackageCadence.Annual => "annual", + MaxGroupTieredPackageCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -32154,22 +30806,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - ScalableMatrixWithUnitPricingCompositePriceFilter, - ScalableMatrixWithUnitPricingCompositePriceFilterFromRaw + MaxGroupTieredPackageCompositePriceFilter, + MaxGroupTieredPackageCompositePriceFilterFromRaw >) )] -public sealed record class ScalableMatrixWithUnitPricingCompositePriceFilter : JsonModel +public sealed record class MaxGroupTieredPackageCompositePriceFilter : JsonModel { /// /// The property of the price to filter on. /// - public required ApiEnum Field + public required ApiEnum Field { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("field"); } init { this._rawData.Set("field", value); } @@ -32178,16 +30830,13 @@ public required ApiEnum /// Should prices that match the filter be included or excluded. /// - public required ApiEnum< - string, - ScalableMatrixWithUnitPricingCompositePriceFilterOperator - > Operator + public required ApiEnum Operator { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("operator"); } init { this._rawData.Set("operator", value); } @@ -32220,14 +30869,14 @@ public override void Validate() _ = this.Values; } - public ScalableMatrixWithUnitPricingCompositePriceFilter() { } + public MaxGroupTieredPackageCompositePriceFilter() { } - public ScalableMatrixWithUnitPricingCompositePriceFilter( - ScalableMatrixWithUnitPricingCompositePriceFilter scalableMatrixWithUnitPricingCompositePriceFilter + public MaxGroupTieredPackageCompositePriceFilter( + MaxGroupTieredPackageCompositePriceFilter maxGroupTieredPackageCompositePriceFilter ) - : base(scalableMatrixWithUnitPricingCompositePriceFilter) { } + : base(maxGroupTieredPackageCompositePriceFilter) { } - public ScalableMatrixWithUnitPricingCompositePriceFilter( + public MaxGroupTieredPackageCompositePriceFilter( IReadOnlyDictionary rawData ) { @@ -32236,14 +30885,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ScalableMatrixWithUnitPricingCompositePriceFilter(FrozenDictionary rawData) + MaxGroupTieredPackageCompositePriceFilter(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ScalableMatrixWithUnitPricingCompositePriceFilter FromRawUnchecked( + /// + public static MaxGroupTieredPackageCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -32251,20 +30900,20 @@ IReadOnlyDictionary rawData } } -class ScalableMatrixWithUnitPricingCompositePriceFilterFromRaw - : IFromRawJson +class MaxGroupTieredPackageCompositePriceFilterFromRaw + : IFromRawJson { /// - public ScalableMatrixWithUnitPricingCompositePriceFilter FromRawUnchecked( + public MaxGroupTieredPackageCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => ScalableMatrixWithUnitPricingCompositePriceFilter.FromRawUnchecked(rawData); + ) => MaxGroupTieredPackageCompositePriceFilter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(ScalableMatrixWithUnitPricingCompositePriceFilterFieldConverter))] -public enum ScalableMatrixWithUnitPricingCompositePriceFilterField +[JsonConverter(typeof(MaxGroupTieredPackageCompositePriceFilterFieldConverter))] +public enum MaxGroupTieredPackageCompositePriceFilterField { PriceID, ItemID, @@ -32273,10 +30922,10 @@ public enum ScalableMatrixWithUnitPricingCompositePriceFilterField PricingUnitID, } -sealed class ScalableMatrixWithUnitPricingCompositePriceFilterFieldConverter - : JsonConverter +sealed class MaxGroupTieredPackageCompositePriceFilterFieldConverter + : JsonConverter { - public override ScalableMatrixWithUnitPricingCompositePriceFilterField Read( + public override MaxGroupTieredPackageCompositePriceFilterField Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -32284,19 +30933,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "price_id" => ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, - "item_id" => ScalableMatrixWithUnitPricingCompositePriceFilterField.ItemID, - "price_type" => ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceType, - "currency" => ScalableMatrixWithUnitPricingCompositePriceFilterField.Currency, - "pricing_unit_id" => - ScalableMatrixWithUnitPricingCompositePriceFilterField.PricingUnitID, - _ => (ScalableMatrixWithUnitPricingCompositePriceFilterField)(-1), + "price_id" => MaxGroupTieredPackageCompositePriceFilterField.PriceID, + "item_id" => MaxGroupTieredPackageCompositePriceFilterField.ItemID, + "price_type" => MaxGroupTieredPackageCompositePriceFilterField.PriceType, + "currency" => MaxGroupTieredPackageCompositePriceFilterField.Currency, + "pricing_unit_id" => MaxGroupTieredPackageCompositePriceFilterField.PricingUnitID, + _ => (MaxGroupTieredPackageCompositePriceFilterField)(-1), }; } public override void Write( Utf8JsonWriter writer, - ScalableMatrixWithUnitPricingCompositePriceFilterField value, + MaxGroupTieredPackageCompositePriceFilterField value, JsonSerializerOptions options ) { @@ -32304,12 +30952,11 @@ JsonSerializerOptions options writer, value switch { - ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID => "price_id", - ScalableMatrixWithUnitPricingCompositePriceFilterField.ItemID => "item_id", - ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceType => "price_type", - ScalableMatrixWithUnitPricingCompositePriceFilterField.Currency => "currency", - ScalableMatrixWithUnitPricingCompositePriceFilterField.PricingUnitID => - "pricing_unit_id", + MaxGroupTieredPackageCompositePriceFilterField.PriceID => "price_id", + MaxGroupTieredPackageCompositePriceFilterField.ItemID => "item_id", + MaxGroupTieredPackageCompositePriceFilterField.PriceType => "price_type", + MaxGroupTieredPackageCompositePriceFilterField.Currency => "currency", + MaxGroupTieredPackageCompositePriceFilterField.PricingUnitID => "pricing_unit_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -32322,17 +30969,17 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(ScalableMatrixWithUnitPricingCompositePriceFilterOperatorConverter))] -public enum ScalableMatrixWithUnitPricingCompositePriceFilterOperator +[JsonConverter(typeof(MaxGroupTieredPackageCompositePriceFilterOperatorConverter))] +public enum MaxGroupTieredPackageCompositePriceFilterOperator { Includes, Excludes, } -sealed class ScalableMatrixWithUnitPricingCompositePriceFilterOperatorConverter - : JsonConverter +sealed class MaxGroupTieredPackageCompositePriceFilterOperatorConverter + : JsonConverter { - public override ScalableMatrixWithUnitPricingCompositePriceFilterOperator Read( + public override MaxGroupTieredPackageCompositePriceFilterOperator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -32340,15 +30987,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, - "excludes" => ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Excludes, - _ => (ScalableMatrixWithUnitPricingCompositePriceFilterOperator)(-1), + "includes" => MaxGroupTieredPackageCompositePriceFilterOperator.Includes, + "excludes" => MaxGroupTieredPackageCompositePriceFilterOperator.Excludes, + _ => (MaxGroupTieredPackageCompositePriceFilterOperator)(-1), }; } public override void Write( Utf8JsonWriter writer, - ScalableMatrixWithUnitPricingCompositePriceFilterOperator value, + MaxGroupTieredPackageCompositePriceFilterOperator value, JsonSerializerOptions options ) { @@ -32356,8 +31003,8 @@ JsonSerializerOptions options writer, value switch { - ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes => "includes", - ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Excludes => "excludes", + MaxGroupTieredPackageCompositePriceFilterOperator.Includes => "includes", + MaxGroupTieredPackageCompositePriceFilterOperator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -32367,8 +31014,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(ScalableMatrixWithUnitPricingConversionRateConfigConverter))] -public record class ScalableMatrixWithUnitPricingConversionRateConfig : ModelBase +[JsonConverter(typeof(MaxGroupTieredPackageConversionRateConfigConverter))] +public record class MaxGroupTieredPackageConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -32385,7 +31032,7 @@ public JsonElement Json } } - public ScalableMatrixWithUnitPricingConversionRateConfig( + public MaxGroupTieredPackageConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -32394,7 +31041,7 @@ public ScalableMatrixWithUnitPricingConversionRateConfig( this._element = element; } - public ScalableMatrixWithUnitPricingConversionRateConfig( + public MaxGroupTieredPackageConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -32403,7 +31050,7 @@ public ScalableMatrixWithUnitPricingConversionRateConfig( this._element = element; } - public ScalableMatrixWithUnitPricingConversionRateConfig(JsonElement element) + public MaxGroupTieredPackageConversionRateConfig(JsonElement element) { this._element = element; } @@ -32485,7 +31132,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ScalableMatrixWithUnitPricingConversionRateConfig" + "Data did not match any variant of MaxGroupTieredPackageConversionRateConfig" ); } } @@ -32521,16 +31168,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ScalableMatrixWithUnitPricingConversionRateConfig" + "Data did not match any variant of MaxGroupTieredPackageConversionRateConfig" ), }; } - public static implicit operator ScalableMatrixWithUnitPricingConversionRateConfig( + public static implicit operator MaxGroupTieredPackageConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ScalableMatrixWithUnitPricingConversionRateConfig( + public static implicit operator MaxGroupTieredPackageConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -32549,13 +31196,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ScalableMatrixWithUnitPricingConversionRateConfig" + "Data did not match any variant of MaxGroupTieredPackageConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ScalableMatrixWithUnitPricingConversionRateConfig? other) + public virtual bool Equals(MaxGroupTieredPackageConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -32569,10 +31216,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class ScalableMatrixWithUnitPricingConversionRateConfigConverter - : JsonConverter +sealed class MaxGroupTieredPackageConversionRateConfigConverter + : JsonConverter { - public override ScalableMatrixWithUnitPricingConversionRateConfig? Read( + public override MaxGroupTieredPackageConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -32637,14 +31284,14 @@ JsonSerializerOptions options } default: { - return new ScalableMatrixWithUnitPricingConversionRateConfig(element); + return new MaxGroupTieredPackageConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ScalableMatrixWithUnitPricingConversionRateConfig value, + MaxGroupTieredPackageConversionRateConfig value, JsonSerializerOptions options ) { @@ -32652,159 +31299,80 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(ScalableMatrixWithUnitPricingPriceTypeConverter))] -public enum ScalableMatrixWithUnitPricingPriceType -{ - UsagePrice, - FixedPrice, - CompositePrice, -} - -sealed class ScalableMatrixWithUnitPricingPriceTypeConverter - : JsonConverter -{ - public override ScalableMatrixWithUnitPricingPriceType Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "usage_price" => ScalableMatrixWithUnitPricingPriceType.UsagePrice, - "fixed_price" => ScalableMatrixWithUnitPricingPriceType.FixedPrice, - "composite_price" => ScalableMatrixWithUnitPricingPriceType.CompositePrice, - _ => (ScalableMatrixWithUnitPricingPriceType)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - ScalableMatrixWithUnitPricingPriceType value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - ScalableMatrixWithUnitPricingPriceType.UsagePrice => "usage_price", - ScalableMatrixWithUnitPricingPriceType.FixedPrice => "fixed_price", - ScalableMatrixWithUnitPricingPriceType.CompositePrice => "composite_price", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} - /// -/// Configuration for scalable_matrix_with_unit_pricing pricing +/// Configuration for max_group_tiered_package pricing /// [JsonConverter( typeof(JsonModelConverter< - ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig, - ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigFromRaw + MaxGroupTieredPackageMaxGroupTieredPackageConfig, + MaxGroupTieredPackageMaxGroupTieredPackageConfigFromRaw >) )] -public sealed record class ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig - : JsonModel +public sealed record class MaxGroupTieredPackageMaxGroupTieredPackageConfig : JsonModel { /// - /// Used to determine the unit rate - /// - public required string FirstDimension - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("first_dimension"); - } - init { this._rawData.Set("first_dimension", value); } - } - - /// - /// Apply a scaling factor to each dimension + /// The event property used to group before tiering the group with the highest value /// - public required IReadOnlyList MatrixScalingFactors + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("matrix_scaling_factors"); - } - init - { - this._rawData.Set< - ImmutableArray - >("matrix_scaling_factors", ImmutableArray.ToImmutableArray(value)); + return this._rawData.GetNotNullClass("grouping_key"); } + init { this._rawData.Set("grouping_key", value); } } - /// - /// The final unit price to rate against the output of the matrix - /// - public required string UnitPrice + public required string PackageSize { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_price"); + return this._rawData.GetNotNullClass("package_size"); } - init { this._rawData.Set("unit_price", value); } + init { this._rawData.Set("package_size", value); } } /// - /// If true, the unit price will be prorated to the billing period + /// Apply tiered pricing to the largest group after grouping with the provided key. /// - public bool? Prorate + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorate"); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); } - init { this._rawData.Set("prorate", value); } - } - - /// - /// Used to determine the unit rate (optional) - /// - public string? SecondDimension - { - get + init { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("second_dimension"); + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("second_dimension", value); } } /// public override void Validate() { - _ = this.FirstDimension; - foreach (var item in this.MatrixScalingFactors) + _ = this.GroupingKey; + _ = this.PackageSize; + foreach (var item in this.Tiers) { item.Validate(); } - _ = this.UnitPrice; - _ = this.Prorate; - _ = this.SecondDimension; } - public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig() { } + public MaxGroupTieredPackageMaxGroupTieredPackageConfig() { } - public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig( - ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + public MaxGroupTieredPackageMaxGroupTieredPackageConfig( + MaxGroupTieredPackageMaxGroupTieredPackageConfig maxGroupTieredPackageMaxGroupTieredPackageConfig ) - : base(scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig) { } + : base(maxGroupTieredPackageMaxGroupTieredPackageConfig) { } - public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig( + public MaxGroupTieredPackageMaxGroupTieredPackageConfig( IReadOnlyDictionary rawData ) { @@ -32813,16 +31381,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig( - FrozenDictionary rawData - ) + MaxGroupTieredPackageMaxGroupTieredPackageConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig FromRawUnchecked( + /// + public static MaxGroupTieredPackageMaxGroupTieredPackageConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -32830,74 +31396,64 @@ IReadOnlyDictionary rawData } } -class ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigFromRaw - : IFromRawJson +class MaxGroupTieredPackageMaxGroupTieredPackageConfigFromRaw + : IFromRawJson { /// - public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig FromRawUnchecked( + public MaxGroupTieredPackageMaxGroupTieredPackageConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig.FromRawUnchecked(rawData); + ) => MaxGroupTieredPackageMaxGroupTieredPackageConfig.FromRawUnchecked(rawData); } /// -/// Configuration for a single matrix scaling factor +/// Configuration for a single tier /// [JsonConverter( typeof(JsonModelConverter< - ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor, - ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactorFromRaw + MaxGroupTieredPackageMaxGroupTieredPackageConfigTier, + MaxGroupTieredPackageMaxGroupTieredPackageConfigTierFromRaw >) )] -public sealed record class ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor - : JsonModel +public sealed record class MaxGroupTieredPackageMaxGroupTieredPackageConfigTier : JsonModel { - public required string FirstDimensionValue - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("first_dimension_value"); - } - init { this._rawData.Set("first_dimension_value", value); } - } - - public required string ScalingFactor + public required string TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("scaling_factor"); + return this._rawData.GetNotNullClass("tier_lower_bound"); } - init { this._rawData.Set("scaling_factor", value); } + init { this._rawData.Set("tier_lower_bound", value); } } - public string? SecondDimensionValue + /// + /// Per unit amount + /// + public required string UnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("second_dimension_value"); + return this._rawData.GetNotNullClass("unit_amount"); } - init { this._rawData.Set("second_dimension_value", value); } + init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.FirstDimensionValue; - _ = this.ScalingFactor; - _ = this.SecondDimensionValue; + _ = this.TierLowerBound; + _ = this.UnitAmount; } - public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor() { } + public MaxGroupTieredPackageMaxGroupTieredPackageConfigTier() { } - public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor( - ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + public MaxGroupTieredPackageMaxGroupTieredPackageConfigTier( + MaxGroupTieredPackageMaxGroupTieredPackageConfigTier maxGroupTieredPackageMaxGroupTieredPackageConfigTier ) - : base(scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor) - { } + : base(maxGroupTieredPackageMaxGroupTieredPackageConfigTier) { } - public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor( + public MaxGroupTieredPackageMaxGroupTieredPackageConfigTier( IReadOnlyDictionary rawData ) { @@ -32906,7 +31462,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor( + MaxGroupTieredPackageMaxGroupTieredPackageConfigTier( FrozenDictionary rawData ) { @@ -32914,8 +31470,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor FromRawUnchecked( + /// + public static MaxGroupTieredPackageMaxGroupTieredPackageConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -32923,25 +31479,66 @@ IReadOnlyDictionary rawData } } -class ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactorFromRaw - : IFromRawJson +class MaxGroupTieredPackageMaxGroupTieredPackageConfigTierFromRaw + : IFromRawJson { /// - public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor FromRawUnchecked( + public MaxGroupTieredPackageMaxGroupTieredPackageConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => - ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor.FromRawUnchecked( - rawData + ) => MaxGroupTieredPackageMaxGroupTieredPackageConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(MaxGroupTieredPackagePriceTypeConverter))] +public enum MaxGroupTieredPackagePriceType +{ + UsagePrice, + FixedPrice, + CompositePrice, +} + +sealed class MaxGroupTieredPackagePriceTypeConverter : JsonConverter +{ + public override MaxGroupTieredPackagePriceType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "usage_price" => MaxGroupTieredPackagePriceType.UsagePrice, + "fixed_price" => MaxGroupTieredPackagePriceType.FixedPrice, + "composite_price" => MaxGroupTieredPackagePriceType.CompositePrice, + _ => (MaxGroupTieredPackagePriceType)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + MaxGroupTieredPackagePriceType value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + MaxGroupTieredPackagePriceType.UsagePrice => "usage_price", + MaxGroupTieredPackagePriceType.FixedPrice => "fixed_price", + MaxGroupTieredPackagePriceType.CompositePrice => "composite_price", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options ); + } } [JsonConverter( - typeof(JsonModelConverter< - ScalableMatrixWithTieredPricing, - ScalableMatrixWithTieredPricingFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class ScalableMatrixWithTieredPricing : JsonModel +public sealed record class ScalableMatrixWithUnitPricing : JsonModel { public required string ID { @@ -32975,42 +31572,42 @@ public required BillingCycleConfiguration BillingCycleConfiguration init { this._rawData.Set("billing_cycle_configuration", value); } } - public required ApiEnum BillingMode + public required ApiEnum BillingMode { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("billing_mode"); } init { this._rawData.Set("billing_mode", value); } } - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } } - public required IReadOnlyList? CompositePriceFilters + public required IReadOnlyList? CompositePriceFilters { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("composite_price_filters"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "composite_price_filters", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -33027,12 +31624,12 @@ public required double? ConversionRate init { this._rawData.Set("conversion_rate", value); } } - public required ScalableMatrixWithTieredPricingConversionRateConfig? ConversionRateConfig + public required ScalableMatrixWithUnitPricingConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -33224,13 +31821,13 @@ public required long? PlanPhaseOrder init { this._rawData.Set("plan_phase_order", value); } } - public required ApiEnum PriceType + public required ApiEnum PriceType { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("price_type"); } init { this._rawData.Set("price_type", value); } @@ -33251,18 +31848,18 @@ public required string? ReplacesPriceID } /// - /// Configuration for scalable_matrix_with_tiered_pricing pricing + /// Configuration for scalable_matrix_with_unit_pricing pricing /// - public required ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig ScalableMatrixWithTieredPricingConfig + public required ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig ScalableMatrixWithUnitPricingConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "scalable_matrix_with_tiered_pricing_config" + return this._rawData.GetNotNullClass( + "scalable_matrix_with_unit_pricing_config" ); } - init { this._rawData.Set("scalable_matrix_with_tiered_pricing_config", value); } + init { this._rawData.Set("scalable_matrix_with_unit_pricing_config", value); } } public DimensionalPriceConfiguration? DimensionalPriceConfiguration @@ -33307,7 +31904,7 @@ public override void Validate() if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing") + JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing") ) ) { @@ -33317,34 +31914,34 @@ public override void Validate() _ = this.PlanPhaseOrder; this.PriceType.Validate(); _ = this.ReplacesPriceID; - this.ScalableMatrixWithTieredPricingConfig.Validate(); + this.ScalableMatrixWithUnitPricingConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public ScalableMatrixWithTieredPricing() + public ScalableMatrixWithUnitPricing() { - this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing"); + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing"); } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public ScalableMatrixWithTieredPricing( - ScalableMatrixWithTieredPricing scalableMatrixWithTieredPricing + public ScalableMatrixWithUnitPricing( + ScalableMatrixWithUnitPricing scalableMatrixWithUnitPricing ) - : base(scalableMatrixWithTieredPricing) { } + : base(scalableMatrixWithUnitPricing) { } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public ScalableMatrixWithTieredPricing(IReadOnlyDictionary rawData) + public ScalableMatrixWithUnitPricing(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing"); + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing"); } #pragma warning disable CS8618 @@ -33352,14 +31949,14 @@ public ScalableMatrixWithTieredPricing(IReadOnlyDictionary "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] [SetsRequiredMembers] - ScalableMatrixWithTieredPricing(FrozenDictionary rawData) + ScalableMatrixWithUnitPricing(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ScalableMatrixWithTieredPricing FromRawUnchecked( + /// + public static ScalableMatrixWithUnitPricing FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -33367,25 +31964,25 @@ IReadOnlyDictionary rawData } } -class ScalableMatrixWithTieredPricingFromRaw : IFromRawJson +class ScalableMatrixWithUnitPricingFromRaw : IFromRawJson { /// - public ScalableMatrixWithTieredPricing FromRawUnchecked( + public ScalableMatrixWithUnitPricing FromRawUnchecked( IReadOnlyDictionary rawData - ) => ScalableMatrixWithTieredPricing.FromRawUnchecked(rawData); + ) => ScalableMatrixWithUnitPricing.FromRawUnchecked(rawData); } -[JsonConverter(typeof(ScalableMatrixWithTieredPricingBillingModeConverter))] -public enum ScalableMatrixWithTieredPricingBillingMode +[JsonConverter(typeof(ScalableMatrixWithUnitPricingBillingModeConverter))] +public enum ScalableMatrixWithUnitPricingBillingMode { InAdvance, InArrear, } -sealed class ScalableMatrixWithTieredPricingBillingModeConverter - : JsonConverter +sealed class ScalableMatrixWithUnitPricingBillingModeConverter + : JsonConverter { - public override ScalableMatrixWithTieredPricingBillingMode Read( + public override ScalableMatrixWithUnitPricingBillingMode Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -33393,15 +31990,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "in_advance" => ScalableMatrixWithTieredPricingBillingMode.InAdvance, - "in_arrear" => ScalableMatrixWithTieredPricingBillingMode.InArrear, - _ => (ScalableMatrixWithTieredPricingBillingMode)(-1), + "in_advance" => ScalableMatrixWithUnitPricingBillingMode.InAdvance, + "in_arrear" => ScalableMatrixWithUnitPricingBillingMode.InArrear, + _ => (ScalableMatrixWithUnitPricingBillingMode)(-1), }; } public override void Write( Utf8JsonWriter writer, - ScalableMatrixWithTieredPricingBillingMode value, + ScalableMatrixWithUnitPricingBillingMode value, JsonSerializerOptions options ) { @@ -33409,8 +32006,8 @@ JsonSerializerOptions options writer, value switch { - ScalableMatrixWithTieredPricingBillingMode.InAdvance => "in_advance", - ScalableMatrixWithTieredPricingBillingMode.InArrear => "in_arrear", + ScalableMatrixWithUnitPricingBillingMode.InAdvance => "in_advance", + ScalableMatrixWithUnitPricingBillingMode.InArrear => "in_arrear", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -33420,8 +32017,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(ScalableMatrixWithTieredPricingCadenceConverter))] -public enum ScalableMatrixWithTieredPricingCadence +[JsonConverter(typeof(ScalableMatrixWithUnitPricingCadenceConverter))] +public enum ScalableMatrixWithUnitPricingCadence { OneTime, Monthly, @@ -33431,10 +32028,10 @@ public enum ScalableMatrixWithTieredPricingCadence Custom, } -sealed class ScalableMatrixWithTieredPricingCadenceConverter - : JsonConverter +sealed class ScalableMatrixWithUnitPricingCadenceConverter + : JsonConverter { - public override ScalableMatrixWithTieredPricingCadence Read( + public override ScalableMatrixWithUnitPricingCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -33442,19 +32039,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "one_time" => ScalableMatrixWithTieredPricingCadence.OneTime, - "monthly" => ScalableMatrixWithTieredPricingCadence.Monthly, - "quarterly" => ScalableMatrixWithTieredPricingCadence.Quarterly, - "semi_annual" => ScalableMatrixWithTieredPricingCadence.SemiAnnual, - "annual" => ScalableMatrixWithTieredPricingCadence.Annual, - "custom" => ScalableMatrixWithTieredPricingCadence.Custom, - _ => (ScalableMatrixWithTieredPricingCadence)(-1), + "one_time" => ScalableMatrixWithUnitPricingCadence.OneTime, + "monthly" => ScalableMatrixWithUnitPricingCadence.Monthly, + "quarterly" => ScalableMatrixWithUnitPricingCadence.Quarterly, + "semi_annual" => ScalableMatrixWithUnitPricingCadence.SemiAnnual, + "annual" => ScalableMatrixWithUnitPricingCadence.Annual, + "custom" => ScalableMatrixWithUnitPricingCadence.Custom, + _ => (ScalableMatrixWithUnitPricingCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - ScalableMatrixWithTieredPricingCadence value, + ScalableMatrixWithUnitPricingCadence value, JsonSerializerOptions options ) { @@ -33462,12 +32059,12 @@ JsonSerializerOptions options writer, value switch { - ScalableMatrixWithTieredPricingCadence.OneTime => "one_time", - ScalableMatrixWithTieredPricingCadence.Monthly => "monthly", - ScalableMatrixWithTieredPricingCadence.Quarterly => "quarterly", - ScalableMatrixWithTieredPricingCadence.SemiAnnual => "semi_annual", - ScalableMatrixWithTieredPricingCadence.Annual => "annual", - ScalableMatrixWithTieredPricingCadence.Custom => "custom", + ScalableMatrixWithUnitPricingCadence.OneTime => "one_time", + ScalableMatrixWithUnitPricingCadence.Monthly => "monthly", + ScalableMatrixWithUnitPricingCadence.Quarterly => "quarterly", + ScalableMatrixWithUnitPricingCadence.SemiAnnual => "semi_annual", + ScalableMatrixWithUnitPricingCadence.Annual => "annual", + ScalableMatrixWithUnitPricingCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -33479,22 +32076,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - ScalableMatrixWithTieredPricingCompositePriceFilter, - ScalableMatrixWithTieredPricingCompositePriceFilterFromRaw + ScalableMatrixWithUnitPricingCompositePriceFilter, + ScalableMatrixWithUnitPricingCompositePriceFilterFromRaw >) )] -public sealed record class ScalableMatrixWithTieredPricingCompositePriceFilter : JsonModel +public sealed record class ScalableMatrixWithUnitPricingCompositePriceFilter : JsonModel { /// /// The property of the price to filter on. /// - public required ApiEnum Field + public required ApiEnum Field { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("field"); } init { this._rawData.Set("field", value); } @@ -33505,14 +32102,14 @@ public required ApiEnum public required ApiEnum< string, - ScalableMatrixWithTieredPricingCompositePriceFilterOperator + ScalableMatrixWithUnitPricingCompositePriceFilterOperator > Operator { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("operator"); } init { this._rawData.Set("operator", value); } @@ -33545,14 +32142,14 @@ public override void Validate() _ = this.Values; } - public ScalableMatrixWithTieredPricingCompositePriceFilter() { } + public ScalableMatrixWithUnitPricingCompositePriceFilter() { } - public ScalableMatrixWithTieredPricingCompositePriceFilter( - ScalableMatrixWithTieredPricingCompositePriceFilter scalableMatrixWithTieredPricingCompositePriceFilter + public ScalableMatrixWithUnitPricingCompositePriceFilter( + ScalableMatrixWithUnitPricingCompositePriceFilter scalableMatrixWithUnitPricingCompositePriceFilter ) - : base(scalableMatrixWithTieredPricingCompositePriceFilter) { } + : base(scalableMatrixWithUnitPricingCompositePriceFilter) { } - public ScalableMatrixWithTieredPricingCompositePriceFilter( + public ScalableMatrixWithUnitPricingCompositePriceFilter( IReadOnlyDictionary rawData ) { @@ -33561,16 +32158,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ScalableMatrixWithTieredPricingCompositePriceFilter( - FrozenDictionary rawData - ) + ScalableMatrixWithUnitPricingCompositePriceFilter(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ScalableMatrixWithTieredPricingCompositePriceFilter FromRawUnchecked( + /// + public static ScalableMatrixWithUnitPricingCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -33578,20 +32173,20 @@ IReadOnlyDictionary rawData } } -class ScalableMatrixWithTieredPricingCompositePriceFilterFromRaw - : IFromRawJson +class ScalableMatrixWithUnitPricingCompositePriceFilterFromRaw + : IFromRawJson { /// - public ScalableMatrixWithTieredPricingCompositePriceFilter FromRawUnchecked( + public ScalableMatrixWithUnitPricingCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => ScalableMatrixWithTieredPricingCompositePriceFilter.FromRawUnchecked(rawData); + ) => ScalableMatrixWithUnitPricingCompositePriceFilter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(ScalableMatrixWithTieredPricingCompositePriceFilterFieldConverter))] -public enum ScalableMatrixWithTieredPricingCompositePriceFilterField +[JsonConverter(typeof(ScalableMatrixWithUnitPricingCompositePriceFilterFieldConverter))] +public enum ScalableMatrixWithUnitPricingCompositePriceFilterField { PriceID, ItemID, @@ -33600,10 +32195,10 @@ public enum ScalableMatrixWithTieredPricingCompositePriceFilterField PricingUnitID, } -sealed class ScalableMatrixWithTieredPricingCompositePriceFilterFieldConverter - : JsonConverter +sealed class ScalableMatrixWithUnitPricingCompositePriceFilterFieldConverter + : JsonConverter { - public override ScalableMatrixWithTieredPricingCompositePriceFilterField Read( + public override ScalableMatrixWithUnitPricingCompositePriceFilterField Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -33611,19 +32206,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "price_id" => ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, - "item_id" => ScalableMatrixWithTieredPricingCompositePriceFilterField.ItemID, - "price_type" => ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceType, - "currency" => ScalableMatrixWithTieredPricingCompositePriceFilterField.Currency, + "price_id" => ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, + "item_id" => ScalableMatrixWithUnitPricingCompositePriceFilterField.ItemID, + "price_type" => ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceType, + "currency" => ScalableMatrixWithUnitPricingCompositePriceFilterField.Currency, "pricing_unit_id" => - ScalableMatrixWithTieredPricingCompositePriceFilterField.PricingUnitID, - _ => (ScalableMatrixWithTieredPricingCompositePriceFilterField)(-1), + ScalableMatrixWithUnitPricingCompositePriceFilterField.PricingUnitID, + _ => (ScalableMatrixWithUnitPricingCompositePriceFilterField)(-1), }; } public override void Write( Utf8JsonWriter writer, - ScalableMatrixWithTieredPricingCompositePriceFilterField value, + ScalableMatrixWithUnitPricingCompositePriceFilterField value, JsonSerializerOptions options ) { @@ -33631,11 +32226,11 @@ JsonSerializerOptions options writer, value switch { - ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID => "price_id", - ScalableMatrixWithTieredPricingCompositePriceFilterField.ItemID => "item_id", - ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceType => "price_type", - ScalableMatrixWithTieredPricingCompositePriceFilterField.Currency => "currency", - ScalableMatrixWithTieredPricingCompositePriceFilterField.PricingUnitID => + ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID => "price_id", + ScalableMatrixWithUnitPricingCompositePriceFilterField.ItemID => "item_id", + ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceType => "price_type", + ScalableMatrixWithUnitPricingCompositePriceFilterField.Currency => "currency", + ScalableMatrixWithUnitPricingCompositePriceFilterField.PricingUnitID => "pricing_unit_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -33649,17 +32244,17 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(ScalableMatrixWithTieredPricingCompositePriceFilterOperatorConverter))] -public enum ScalableMatrixWithTieredPricingCompositePriceFilterOperator +[JsonConverter(typeof(ScalableMatrixWithUnitPricingCompositePriceFilterOperatorConverter))] +public enum ScalableMatrixWithUnitPricingCompositePriceFilterOperator { Includes, Excludes, } -sealed class ScalableMatrixWithTieredPricingCompositePriceFilterOperatorConverter - : JsonConverter +sealed class ScalableMatrixWithUnitPricingCompositePriceFilterOperatorConverter + : JsonConverter { - public override ScalableMatrixWithTieredPricingCompositePriceFilterOperator Read( + public override ScalableMatrixWithUnitPricingCompositePriceFilterOperator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -33667,15 +32262,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, - "excludes" => ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Excludes, - _ => (ScalableMatrixWithTieredPricingCompositePriceFilterOperator)(-1), + "includes" => ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, + "excludes" => ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Excludes, + _ => (ScalableMatrixWithUnitPricingCompositePriceFilterOperator)(-1), }; } public override void Write( Utf8JsonWriter writer, - ScalableMatrixWithTieredPricingCompositePriceFilterOperator value, + ScalableMatrixWithUnitPricingCompositePriceFilterOperator value, JsonSerializerOptions options ) { @@ -33683,8 +32278,8 @@ JsonSerializerOptions options writer, value switch { - ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes => "includes", - ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Excludes => "excludes", + ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes => "includes", + ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -33694,8 +32289,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(ScalableMatrixWithTieredPricingConversionRateConfigConverter))] -public record class ScalableMatrixWithTieredPricingConversionRateConfig : ModelBase +[JsonConverter(typeof(ScalableMatrixWithUnitPricingConversionRateConfigConverter))] +public record class ScalableMatrixWithUnitPricingConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -33712,7 +32307,7 @@ public JsonElement Json } } - public ScalableMatrixWithTieredPricingConversionRateConfig( + public ScalableMatrixWithUnitPricingConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -33721,7 +32316,7 @@ public ScalableMatrixWithTieredPricingConversionRateConfig( this._element = element; } - public ScalableMatrixWithTieredPricingConversionRateConfig( + public ScalableMatrixWithUnitPricingConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -33730,7 +32325,7 @@ public ScalableMatrixWithTieredPricingConversionRateConfig( this._element = element; } - public ScalableMatrixWithTieredPricingConversionRateConfig(JsonElement element) + public ScalableMatrixWithUnitPricingConversionRateConfig(JsonElement element) { this._element = element; } @@ -33812,7 +32407,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ScalableMatrixWithTieredPricingConversionRateConfig" + "Data did not match any variant of ScalableMatrixWithUnitPricingConversionRateConfig" ); } } @@ -33848,16 +32443,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ScalableMatrixWithTieredPricingConversionRateConfig" + "Data did not match any variant of ScalableMatrixWithUnitPricingConversionRateConfig" ), }; } - public static implicit operator ScalableMatrixWithTieredPricingConversionRateConfig( + public static implicit operator ScalableMatrixWithUnitPricingConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ScalableMatrixWithTieredPricingConversionRateConfig( + public static implicit operator ScalableMatrixWithUnitPricingConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -33876,13 +32471,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ScalableMatrixWithTieredPricingConversionRateConfig" + "Data did not match any variant of ScalableMatrixWithUnitPricingConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ScalableMatrixWithTieredPricingConversionRateConfig? other) + public virtual bool Equals(ScalableMatrixWithUnitPricingConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -33896,10 +32491,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class ScalableMatrixWithTieredPricingConversionRateConfigConverter - : JsonConverter +sealed class ScalableMatrixWithUnitPricingConversionRateConfigConverter + : JsonConverter { - public override ScalableMatrixWithTieredPricingConversionRateConfig? Read( + public override ScalableMatrixWithUnitPricingConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -33964,14 +32559,14 @@ JsonSerializerOptions options } default: { - return new ScalableMatrixWithTieredPricingConversionRateConfig(element); + return new ScalableMatrixWithUnitPricingConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ScalableMatrixWithTieredPricingConversionRateConfig value, + ScalableMatrixWithUnitPricingConversionRateConfig value, JsonSerializerOptions options ) { @@ -33979,18 +32574,18 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(ScalableMatrixWithTieredPricingPriceTypeConverter))] -public enum ScalableMatrixWithTieredPricingPriceType +[JsonConverter(typeof(ScalableMatrixWithUnitPricingPriceTypeConverter))] +public enum ScalableMatrixWithUnitPricingPriceType { UsagePrice, FixedPrice, CompositePrice, } -sealed class ScalableMatrixWithTieredPricingPriceTypeConverter - : JsonConverter +sealed class ScalableMatrixWithUnitPricingPriceTypeConverter + : JsonConverter { - public override ScalableMatrixWithTieredPricingPriceType Read( + public override ScalableMatrixWithUnitPricingPriceType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -33998,16 +32593,16 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "usage_price" => ScalableMatrixWithTieredPricingPriceType.UsagePrice, - "fixed_price" => ScalableMatrixWithTieredPricingPriceType.FixedPrice, - "composite_price" => ScalableMatrixWithTieredPricingPriceType.CompositePrice, - _ => (ScalableMatrixWithTieredPricingPriceType)(-1), + "usage_price" => ScalableMatrixWithUnitPricingPriceType.UsagePrice, + "fixed_price" => ScalableMatrixWithUnitPricingPriceType.FixedPrice, + "composite_price" => ScalableMatrixWithUnitPricingPriceType.CompositePrice, + _ => (ScalableMatrixWithUnitPricingPriceType)(-1), }; } public override void Write( Utf8JsonWriter writer, - ScalableMatrixWithTieredPricingPriceType value, + ScalableMatrixWithUnitPricingPriceType value, JsonSerializerOptions options ) { @@ -34015,9 +32610,9 @@ JsonSerializerOptions options writer, value switch { - ScalableMatrixWithTieredPricingPriceType.UsagePrice => "usage_price", - ScalableMatrixWithTieredPricingPriceType.FixedPrice => "fixed_price", - ScalableMatrixWithTieredPricingPriceType.CompositePrice => "composite_price", + ScalableMatrixWithUnitPricingPriceType.UsagePrice => "usage_price", + ScalableMatrixWithUnitPricingPriceType.FixedPrice => "fixed_price", + ScalableMatrixWithUnitPricingPriceType.CompositePrice => "composite_price", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -34028,19 +32623,19 @@ JsonSerializerOptions options } /// -/// Configuration for scalable_matrix_with_tiered_pricing pricing +/// Configuration for scalable_matrix_with_unit_pricing pricing /// [JsonConverter( typeof(JsonModelConverter< - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig, - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigFromRaw + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig, + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigFromRaw >) )] -public sealed record class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig +public sealed record class ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig : JsonModel { /// - /// Used for the scalable matrix first dimension + /// Used to determine the unit rate /// public required string FirstDimension { @@ -34055,42 +32650,51 @@ public required string FirstDimension /// /// Apply a scaling factor to each dimension /// - public required IReadOnlyList MatrixScalingFactors + public required IReadOnlyList MatrixScalingFactors { get { this._rawData.Freeze(); return this._rawData.GetNotNullStruct< - ImmutableArray + ImmutableArray >("matrix_scaling_factors"); } init { this._rawData.Set< - ImmutableArray + ImmutableArray >("matrix_scaling_factors", ImmutableArray.ToImmutableArray(value)); } } - public required IReadOnlyList Tiers + /// + /// The final unit price to rate against the output of the matrix + /// + public required string UnitPrice { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + return this._rawData.GetNotNullClass("unit_price"); } - init + init { this._rawData.Set("unit_price", value); } + } + + /// + /// If true, the unit price will be prorated to the billing period + /// + public bool? Prorate + { + get { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("prorate"); } + init { this._rawData.Set("prorate", value); } } /// - /// Used for the scalable matrix second dimension (optional) + /// Used to determine the unit rate (optional) /// public string? SecondDimension { @@ -34110,21 +32714,19 @@ public override void Validate() { item.Validate(); } - foreach (var item in this.Tiers) - { - item.Validate(); - } + _ = this.UnitPrice; + _ = this.Prorate; _ = this.SecondDimension; } - public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig() { } + public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig() { } - public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig( - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig( + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig ) - : base(scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig) { } + : base(scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig) { } - public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig( + public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig( IReadOnlyDictionary rawData ) { @@ -34133,7 +32735,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig( + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig( FrozenDictionary rawData ) { @@ -34141,8 +32743,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig FromRawUnchecked( + /// + public static ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -34150,16 +32752,13 @@ IReadOnlyDictionary rawData } } -class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigFromRaw - : IFromRawJson +class ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigFromRaw + : IFromRawJson { /// - public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig FromRawUnchecked( + public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig.FromRawUnchecked( - rawData - ); + ) => ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig.FromRawUnchecked(rawData); } /// @@ -34167,11 +32766,11 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor, - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactorFromRaw + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor, + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactorFromRaw >) )] -public sealed record class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor +public sealed record class ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor : JsonModel { public required string FirstDimensionValue @@ -34212,17 +32811,15 @@ public override void Validate() _ = this.SecondDimensionValue; } - public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor() - { } + public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor() { } - public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor( - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor( + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor ) - : base( - scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor - ) { } + : base(scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor) + { } - public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor( + public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor( IReadOnlyDictionary rawData ) { @@ -34231,7 +32828,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor( + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor( FrozenDictionary rawData ) { @@ -34239,8 +32836,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor FromRawUnchecked( + /// + public static ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -34248,104 +32845,25 @@ IReadOnlyDictionary rawData } } -class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactorFromRaw - : IFromRawJson +class ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactorFromRaw + : IFromRawJson { /// - public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor FromRawUnchecked( + public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor FromRawUnchecked( IReadOnlyDictionary rawData ) => - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor.FromRawUnchecked( + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor.FromRawUnchecked( rawData ); } -/// -/// Configuration for a single tier entry with business logic -/// [JsonConverter( typeof(JsonModelConverter< - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier, - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTierFromRaw + ScalableMatrixWithTieredPricing, + ScalableMatrixWithTieredPricingFromRaw >) )] -public sealed record class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier - : JsonModel -{ - public required string TierLowerBound - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); - } - init { this._rawData.Set("tier_lower_bound", value); } - } - - public required string UnitAmount - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); - } - init { this._rawData.Set("unit_amount", value); } - } - - /// - public override void Validate() - { - _ = this.TierLowerBound; - _ = this.UnitAmount; - } - - public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier() { } - - public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier( - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier - ) - : base(scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier) { } - - public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTierFromRaw - : IFromRawJson -{ - /// - public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier.FromRawUnchecked( - rawData - ); -} - -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class CumulativeGroupedBulk : JsonModel +public sealed record class ScalableMatrixWithTieredPricing : JsonModel { public required string ID { @@ -34379,42 +32897,42 @@ public required BillingCycleConfiguration BillingCycleConfiguration init { this._rawData.Set("billing_cycle_configuration", value); } } - public required ApiEnum BillingMode + public required ApiEnum BillingMode { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( - "billing_mode" - ); + return this._rawData.GetNotNullClass< + ApiEnum + >("billing_mode"); } init { this._rawData.Set("billing_mode", value); } } - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( - "cadence" - ); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); } init { this._rawData.Set("cadence", value); } } - public required IReadOnlyList? CompositePriceFilters + public required IReadOnlyList? CompositePriceFilters { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("composite_price_filters"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "composite_price_filters", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -34431,12 +32949,12 @@ public required double? ConversionRate init { this._rawData.Set("conversion_rate", value); } } - public required CumulativeGroupedBulkConversionRateConfig? ConversionRateConfig + public required ScalableMatrixWithTieredPricingConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -34463,21 +32981,6 @@ public required Allocation? CreditAllocation init { this._rawData.Set("credit_allocation", value); } } - /// - /// Configuration for cumulative_grouped_bulk pricing - /// - public required CumulativeGroupedBulkCumulativeGroupedBulkConfig CumulativeGroupedBulkConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "cumulative_grouped_bulk_config" - ); - } - init { this._rawData.Set("cumulative_grouped_bulk_config", value); } - } - public required string Currency { get @@ -34643,14 +33146,14 @@ public required long? PlanPhaseOrder init { this._rawData.Set("plan_phase_order", value); } } - public required ApiEnum PriceType + public required ApiEnum PriceType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( - "price_type" - ); + return this._rawData.GetNotNullClass< + ApiEnum + >("price_type"); } init { this._rawData.Set("price_type", value); } } @@ -34669,6 +33172,21 @@ public required string? ReplacesPriceID init { this._rawData.Set("replaces_price_id", value); } } + /// + /// Configuration for scalable_matrix_with_tiered_pricing pricing + /// + public required ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig ScalableMatrixWithTieredPricingConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "scalable_matrix_with_tiered_pricing_config" + ); + } + init { this._rawData.Set("scalable_matrix_with_tiered_pricing_config", value); } + } + public DimensionalPriceConfiguration? DimensionalPriceConfiguration { get @@ -34697,7 +33215,6 @@ public override void Validate() this.ConversionRateConfig?.Validate(); _ = this.CreatedAt; this.CreditAllocation?.Validate(); - this.CumulativeGroupedBulkConfig.Validate(); _ = this.Currency; this.Discount?.Validate(); _ = this.ExternalPriceID; @@ -34712,7 +33229,7 @@ public override void Validate() if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("cumulative_grouped_bulk") + JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing") ) ) { @@ -34722,31 +33239,34 @@ public override void Validate() _ = this.PlanPhaseOrder; this.PriceType.Validate(); _ = this.ReplacesPriceID; + this.ScalableMatrixWithTieredPricingConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public CumulativeGroupedBulk() + public ScalableMatrixWithTieredPricing() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_bulk"); + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing"); } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public CumulativeGroupedBulk(CumulativeGroupedBulk cumulativeGroupedBulk) - : base(cumulativeGroupedBulk) { } + public ScalableMatrixWithTieredPricing( + ScalableMatrixWithTieredPricing scalableMatrixWithTieredPricing + ) + : base(scalableMatrixWithTieredPricing) { } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public CumulativeGroupedBulk(IReadOnlyDictionary rawData) + public ScalableMatrixWithTieredPricing(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_bulk"); + this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing"); } #pragma warning disable CS8618 @@ -34754,14 +33274,14 @@ public CumulativeGroupedBulk(IReadOnlyDictionary rawData) "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] [SetsRequiredMembers] - CumulativeGroupedBulk(FrozenDictionary rawData) + ScalableMatrixWithTieredPricing(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static CumulativeGroupedBulk FromRawUnchecked( + /// + public static ScalableMatrixWithTieredPricing FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -34769,25 +33289,25 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedBulkFromRaw : IFromRawJson +class ScalableMatrixWithTieredPricingFromRaw : IFromRawJson { /// - public CumulativeGroupedBulk FromRawUnchecked( + public ScalableMatrixWithTieredPricing FromRawUnchecked( IReadOnlyDictionary rawData - ) => CumulativeGroupedBulk.FromRawUnchecked(rawData); + ) => ScalableMatrixWithTieredPricing.FromRawUnchecked(rawData); } -[JsonConverter(typeof(CumulativeGroupedBulkBillingModeConverter))] -public enum CumulativeGroupedBulkBillingMode +[JsonConverter(typeof(ScalableMatrixWithTieredPricingBillingModeConverter))] +public enum ScalableMatrixWithTieredPricingBillingMode { InAdvance, InArrear, } -sealed class CumulativeGroupedBulkBillingModeConverter - : JsonConverter +sealed class ScalableMatrixWithTieredPricingBillingModeConverter + : JsonConverter { - public override CumulativeGroupedBulkBillingMode Read( + public override ScalableMatrixWithTieredPricingBillingMode Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -34795,15 +33315,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "in_advance" => CumulativeGroupedBulkBillingMode.InAdvance, - "in_arrear" => CumulativeGroupedBulkBillingMode.InArrear, - _ => (CumulativeGroupedBulkBillingMode)(-1), + "in_advance" => ScalableMatrixWithTieredPricingBillingMode.InAdvance, + "in_arrear" => ScalableMatrixWithTieredPricingBillingMode.InArrear, + _ => (ScalableMatrixWithTieredPricingBillingMode)(-1), }; } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedBulkBillingMode value, + ScalableMatrixWithTieredPricingBillingMode value, JsonSerializerOptions options ) { @@ -34811,8 +33331,8 @@ JsonSerializerOptions options writer, value switch { - CumulativeGroupedBulkBillingMode.InAdvance => "in_advance", - CumulativeGroupedBulkBillingMode.InArrear => "in_arrear", + ScalableMatrixWithTieredPricingBillingMode.InAdvance => "in_advance", + ScalableMatrixWithTieredPricingBillingMode.InArrear => "in_arrear", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -34822,8 +33342,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(CumulativeGroupedBulkCadenceConverter))] -public enum CumulativeGroupedBulkCadence +[JsonConverter(typeof(ScalableMatrixWithTieredPricingCadenceConverter))] +public enum ScalableMatrixWithTieredPricingCadence { OneTime, Monthly, @@ -34833,9 +33353,10 @@ public enum CumulativeGroupedBulkCadence Custom, } -sealed class CumulativeGroupedBulkCadenceConverter : JsonConverter +sealed class ScalableMatrixWithTieredPricingCadenceConverter + : JsonConverter { - public override CumulativeGroupedBulkCadence Read( + public override ScalableMatrixWithTieredPricingCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -34843,19 +33364,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "one_time" => CumulativeGroupedBulkCadence.OneTime, - "monthly" => CumulativeGroupedBulkCadence.Monthly, - "quarterly" => CumulativeGroupedBulkCadence.Quarterly, - "semi_annual" => CumulativeGroupedBulkCadence.SemiAnnual, - "annual" => CumulativeGroupedBulkCadence.Annual, - "custom" => CumulativeGroupedBulkCadence.Custom, - _ => (CumulativeGroupedBulkCadence)(-1), + "one_time" => ScalableMatrixWithTieredPricingCadence.OneTime, + "monthly" => ScalableMatrixWithTieredPricingCadence.Monthly, + "quarterly" => ScalableMatrixWithTieredPricingCadence.Quarterly, + "semi_annual" => ScalableMatrixWithTieredPricingCadence.SemiAnnual, + "annual" => ScalableMatrixWithTieredPricingCadence.Annual, + "custom" => ScalableMatrixWithTieredPricingCadence.Custom, + _ => (ScalableMatrixWithTieredPricingCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedBulkCadence value, + ScalableMatrixWithTieredPricingCadence value, JsonSerializerOptions options ) { @@ -34863,12 +33384,12 @@ JsonSerializerOptions options writer, value switch { - CumulativeGroupedBulkCadence.OneTime => "one_time", - CumulativeGroupedBulkCadence.Monthly => "monthly", - CumulativeGroupedBulkCadence.Quarterly => "quarterly", - CumulativeGroupedBulkCadence.SemiAnnual => "semi_annual", - CumulativeGroupedBulkCadence.Annual => "annual", - CumulativeGroupedBulkCadence.Custom => "custom", + ScalableMatrixWithTieredPricingCadence.OneTime => "one_time", + ScalableMatrixWithTieredPricingCadence.Monthly => "monthly", + ScalableMatrixWithTieredPricingCadence.Quarterly => "quarterly", + ScalableMatrixWithTieredPricingCadence.SemiAnnual => "semi_annual", + ScalableMatrixWithTieredPricingCadence.Annual => "annual", + ScalableMatrixWithTieredPricingCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -34880,22 +33401,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - CumulativeGroupedBulkCompositePriceFilter, - CumulativeGroupedBulkCompositePriceFilterFromRaw + ScalableMatrixWithTieredPricingCompositePriceFilter, + ScalableMatrixWithTieredPricingCompositePriceFilterFromRaw >) )] -public sealed record class CumulativeGroupedBulkCompositePriceFilter : JsonModel +public sealed record class ScalableMatrixWithTieredPricingCompositePriceFilter : JsonModel { /// /// The property of the price to filter on. /// - public required ApiEnum Field + public required ApiEnum Field { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("field"); } init { this._rawData.Set("field", value); } @@ -34904,13 +33425,16 @@ public required ApiEnum /// /// Should prices that match the filter be included or excluded. /// - public required ApiEnum Operator + public required ApiEnum< + string, + ScalableMatrixWithTieredPricingCompositePriceFilterOperator + > Operator { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("operator"); } init { this._rawData.Set("operator", value); } @@ -34943,14 +33467,14 @@ public override void Validate() _ = this.Values; } - public CumulativeGroupedBulkCompositePriceFilter() { } + public ScalableMatrixWithTieredPricingCompositePriceFilter() { } - public CumulativeGroupedBulkCompositePriceFilter( - CumulativeGroupedBulkCompositePriceFilter cumulativeGroupedBulkCompositePriceFilter + public ScalableMatrixWithTieredPricingCompositePriceFilter( + ScalableMatrixWithTieredPricingCompositePriceFilter scalableMatrixWithTieredPricingCompositePriceFilter ) - : base(cumulativeGroupedBulkCompositePriceFilter) { } + : base(scalableMatrixWithTieredPricingCompositePriceFilter) { } - public CumulativeGroupedBulkCompositePriceFilter( + public ScalableMatrixWithTieredPricingCompositePriceFilter( IReadOnlyDictionary rawData ) { @@ -34959,14 +33483,16 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedBulkCompositePriceFilter(FrozenDictionary rawData) + ScalableMatrixWithTieredPricingCompositePriceFilter( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static CumulativeGroupedBulkCompositePriceFilter FromRawUnchecked( + /// + public static ScalableMatrixWithTieredPricingCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -34974,20 +33500,20 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedBulkCompositePriceFilterFromRaw - : IFromRawJson +class ScalableMatrixWithTieredPricingCompositePriceFilterFromRaw + : IFromRawJson { /// - public CumulativeGroupedBulkCompositePriceFilter FromRawUnchecked( + public ScalableMatrixWithTieredPricingCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => CumulativeGroupedBulkCompositePriceFilter.FromRawUnchecked(rawData); + ) => ScalableMatrixWithTieredPricingCompositePriceFilter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(CumulativeGroupedBulkCompositePriceFilterFieldConverter))] -public enum CumulativeGroupedBulkCompositePriceFilterField +[JsonConverter(typeof(ScalableMatrixWithTieredPricingCompositePriceFilterFieldConverter))] +public enum ScalableMatrixWithTieredPricingCompositePriceFilterField { PriceID, ItemID, @@ -34996,10 +33522,10 @@ public enum CumulativeGroupedBulkCompositePriceFilterField PricingUnitID, } -sealed class CumulativeGroupedBulkCompositePriceFilterFieldConverter - : JsonConverter +sealed class ScalableMatrixWithTieredPricingCompositePriceFilterFieldConverter + : JsonConverter { - public override CumulativeGroupedBulkCompositePriceFilterField Read( + public override ScalableMatrixWithTieredPricingCompositePriceFilterField Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -35007,18 +33533,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "price_id" => CumulativeGroupedBulkCompositePriceFilterField.PriceID, - "item_id" => CumulativeGroupedBulkCompositePriceFilterField.ItemID, - "price_type" => CumulativeGroupedBulkCompositePriceFilterField.PriceType, - "currency" => CumulativeGroupedBulkCompositePriceFilterField.Currency, - "pricing_unit_id" => CumulativeGroupedBulkCompositePriceFilterField.PricingUnitID, - _ => (CumulativeGroupedBulkCompositePriceFilterField)(-1), + "price_id" => ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, + "item_id" => ScalableMatrixWithTieredPricingCompositePriceFilterField.ItemID, + "price_type" => ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceType, + "currency" => ScalableMatrixWithTieredPricingCompositePriceFilterField.Currency, + "pricing_unit_id" => + ScalableMatrixWithTieredPricingCompositePriceFilterField.PricingUnitID, + _ => (ScalableMatrixWithTieredPricingCompositePriceFilterField)(-1), }; } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedBulkCompositePriceFilterField value, + ScalableMatrixWithTieredPricingCompositePriceFilterField value, JsonSerializerOptions options ) { @@ -35026,11 +33553,12 @@ JsonSerializerOptions options writer, value switch { - CumulativeGroupedBulkCompositePriceFilterField.PriceID => "price_id", - CumulativeGroupedBulkCompositePriceFilterField.ItemID => "item_id", - CumulativeGroupedBulkCompositePriceFilterField.PriceType => "price_type", - CumulativeGroupedBulkCompositePriceFilterField.Currency => "currency", - CumulativeGroupedBulkCompositePriceFilterField.PricingUnitID => "pricing_unit_id", + ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID => "price_id", + ScalableMatrixWithTieredPricingCompositePriceFilterField.ItemID => "item_id", + ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceType => "price_type", + ScalableMatrixWithTieredPricingCompositePriceFilterField.Currency => "currency", + ScalableMatrixWithTieredPricingCompositePriceFilterField.PricingUnitID => + "pricing_unit_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -35043,17 +33571,17 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(CumulativeGroupedBulkCompositePriceFilterOperatorConverter))] -public enum CumulativeGroupedBulkCompositePriceFilterOperator +[JsonConverter(typeof(ScalableMatrixWithTieredPricingCompositePriceFilterOperatorConverter))] +public enum ScalableMatrixWithTieredPricingCompositePriceFilterOperator { Includes, Excludes, } -sealed class CumulativeGroupedBulkCompositePriceFilterOperatorConverter - : JsonConverter +sealed class ScalableMatrixWithTieredPricingCompositePriceFilterOperatorConverter + : JsonConverter { - public override CumulativeGroupedBulkCompositePriceFilterOperator Read( + public override ScalableMatrixWithTieredPricingCompositePriceFilterOperator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -35061,15 +33589,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => CumulativeGroupedBulkCompositePriceFilterOperator.Includes, - "excludes" => CumulativeGroupedBulkCompositePriceFilterOperator.Excludes, - _ => (CumulativeGroupedBulkCompositePriceFilterOperator)(-1), + "includes" => ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, + "excludes" => ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Excludes, + _ => (ScalableMatrixWithTieredPricingCompositePriceFilterOperator)(-1), }; } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedBulkCompositePriceFilterOperator value, + ScalableMatrixWithTieredPricingCompositePriceFilterOperator value, JsonSerializerOptions options ) { @@ -35077,8 +33605,8 @@ JsonSerializerOptions options writer, value switch { - CumulativeGroupedBulkCompositePriceFilterOperator.Includes => "includes", - CumulativeGroupedBulkCompositePriceFilterOperator.Excludes => "excludes", + ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes => "includes", + ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -35088,8 +33616,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(CumulativeGroupedBulkConversionRateConfigConverter))] -public record class CumulativeGroupedBulkConversionRateConfig : ModelBase +[JsonConverter(typeof(ScalableMatrixWithTieredPricingConversionRateConfigConverter))] +public record class ScalableMatrixWithTieredPricingConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -35106,7 +33634,7 @@ public JsonElement Json } } - public CumulativeGroupedBulkConversionRateConfig( + public ScalableMatrixWithTieredPricingConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -35115,7 +33643,7 @@ public CumulativeGroupedBulkConversionRateConfig( this._element = element; } - public CumulativeGroupedBulkConversionRateConfig( + public ScalableMatrixWithTieredPricingConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -35124,7 +33652,7 @@ public CumulativeGroupedBulkConversionRateConfig( this._element = element; } - public CumulativeGroupedBulkConversionRateConfig(JsonElement element) + public ScalableMatrixWithTieredPricingConversionRateConfig(JsonElement element) { this._element = element; } @@ -35206,7 +33734,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of CumulativeGroupedBulkConversionRateConfig" + "Data did not match any variant of ScalableMatrixWithTieredPricingConversionRateConfig" ); } } @@ -35242,16 +33770,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of CumulativeGroupedBulkConversionRateConfig" + "Data did not match any variant of ScalableMatrixWithTieredPricingConversionRateConfig" ), }; } - public static implicit operator CumulativeGroupedBulkConversionRateConfig( + public static implicit operator ScalableMatrixWithTieredPricingConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator CumulativeGroupedBulkConversionRateConfig( + public static implicit operator ScalableMatrixWithTieredPricingConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -35270,13 +33798,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of CumulativeGroupedBulkConversionRateConfig" + "Data did not match any variant of ScalableMatrixWithTieredPricingConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(CumulativeGroupedBulkConversionRateConfig? other) + public virtual bool Equals(ScalableMatrixWithTieredPricingConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -35290,10 +33818,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class CumulativeGroupedBulkConversionRateConfigConverter - : JsonConverter +sealed class ScalableMatrixWithTieredPricingConversionRateConfigConverter + : JsonConverter { - public override CumulativeGroupedBulkConversionRateConfig? Read( + public override ScalableMatrixWithTieredPricingConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -35358,14 +33886,14 @@ JsonSerializerOptions options } default: { - return new CumulativeGroupedBulkConversionRateConfig(element); + return new ScalableMatrixWithTieredPricingConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedBulkConversionRateConfig value, + ScalableMatrixWithTieredPricingConversionRateConfig value, JsonSerializerOptions options ) { @@ -35373,65 +33901,152 @@ JsonSerializerOptions options } } +[JsonConverter(typeof(ScalableMatrixWithTieredPricingPriceTypeConverter))] +public enum ScalableMatrixWithTieredPricingPriceType +{ + UsagePrice, + FixedPrice, + CompositePrice, +} + +sealed class ScalableMatrixWithTieredPricingPriceTypeConverter + : JsonConverter +{ + public override ScalableMatrixWithTieredPricingPriceType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "usage_price" => ScalableMatrixWithTieredPricingPriceType.UsagePrice, + "fixed_price" => ScalableMatrixWithTieredPricingPriceType.FixedPrice, + "composite_price" => ScalableMatrixWithTieredPricingPriceType.CompositePrice, + _ => (ScalableMatrixWithTieredPricingPriceType)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ScalableMatrixWithTieredPricingPriceType value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ScalableMatrixWithTieredPricingPriceType.UsagePrice => "usage_price", + ScalableMatrixWithTieredPricingPriceType.FixedPrice => "fixed_price", + ScalableMatrixWithTieredPricingPriceType.CompositePrice => "composite_price", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + /// -/// Configuration for cumulative_grouped_bulk pricing +/// Configuration for scalable_matrix_with_tiered_pricing pricing /// [JsonConverter( typeof(JsonModelConverter< - CumulativeGroupedBulkCumulativeGroupedBulkConfig, - CumulativeGroupedBulkCumulativeGroupedBulkConfigFromRaw + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig, + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigFromRaw >) )] -public sealed record class CumulativeGroupedBulkCumulativeGroupedBulkConfig : JsonModel +public sealed record class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + : JsonModel { /// - /// Each tier lower bound must have the same group of values. + /// Used for the scalable matrix first dimension /// - public required IReadOnlyList DimensionValues + public required string FirstDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("first_dimension"); + } + init { this._rawData.Set("first_dimension", value); } + } + + /// + /// Apply a scaling factor to each dimension + /// + public required IReadOnlyList MatrixScalingFactors { get { this._rawData.Freeze(); return this._rawData.GetNotNullStruct< - ImmutableArray - >("dimension_values"); + ImmutableArray + >("matrix_scaling_factors"); } init { this._rawData.Set< - ImmutableArray - >("dimension_values", ImmutableArray.ToImmutableArray(value)); + ImmutableArray + >("matrix_scaling_factors", ImmutableArray.ToImmutableArray(value)); } } - public required string Group + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group"); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); } - init { this._rawData.Set("group", value); } + } + + /// + /// Used for the scalable matrix second dimension (optional) + /// + public string? SecondDimension + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("second_dimension"); + } + init { this._rawData.Set("second_dimension", value); } } /// public override void Validate() { - foreach (var item in this.DimensionValues) + _ = this.FirstDimension; + foreach (var item in this.MatrixScalingFactors) { item.Validate(); } - _ = this.Group; + foreach (var item in this.Tiers) + { + item.Validate(); + } + _ = this.SecondDimension; } - public CumulativeGroupedBulkCumulativeGroupedBulkConfig() { } + public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig() { } - public CumulativeGroupedBulkCumulativeGroupedBulkConfig( - CumulativeGroupedBulkCumulativeGroupedBulkConfig cumulativeGroupedBulkCumulativeGroupedBulkConfig + public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig( + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig ) - : base(cumulativeGroupedBulkCumulativeGroupedBulkConfig) { } + : base(scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig) { } - public CumulativeGroupedBulkCumulativeGroupedBulkConfig( + public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig( IReadOnlyDictionary rawData ) { @@ -35440,14 +34055,16 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedBulkCumulativeGroupedBulkConfig(FrozenDictionary rawData) + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static CumulativeGroupedBulkCumulativeGroupedBulkConfig FromRawUnchecked( + /// + public static ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -35455,82 +34072,79 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedBulkCumulativeGroupedBulkConfigFromRaw - : IFromRawJson +class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigFromRaw + : IFromRawJson { /// - public CumulativeGroupedBulkCumulativeGroupedBulkConfig FromRawUnchecked( + public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => CumulativeGroupedBulkCumulativeGroupedBulkConfig.FromRawUnchecked(rawData); + ) => + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig.FromRawUnchecked( + rawData + ); } /// -/// Configuration for a dimension value entry +/// Configuration for a single matrix scaling factor /// [JsonConverter( typeof(JsonModelConverter< - CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue, - CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValueFromRaw + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor, + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactorFromRaw >) )] -public sealed record class CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue +public sealed record class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor : JsonModel { - /// - /// Grouping key value - /// - public required string GroupingKey + public required string FirstDimensionValue { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("first_dimension_value"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("first_dimension_value", value); } } - /// - /// Tier lower bound - /// - public required string TierLowerBound + public required string ScalingFactor { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("scaling_factor"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("scaling_factor", value); } } - /// - /// Unit amount for this combination - /// - public required string UnitAmount + public string? SecondDimensionValue { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNullableClass("second_dimension_value"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("second_dimension_value", value); } } /// public override void Validate() { - _ = this.GroupingKey; - _ = this.TierLowerBound; - _ = this.UnitAmount; + _ = this.FirstDimensionValue; + _ = this.ScalingFactor; + _ = this.SecondDimensionValue; } - public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue() { } + public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor() + { } - public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( - CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue cumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor( + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor ) - : base(cumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue) { } + : base( + scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + ) { } - public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( + public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor( IReadOnlyDictionary rawData ) { @@ -35539,7 +34153,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor( FrozenDictionary rawData ) { @@ -35547,8 +34161,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue FromRawUnchecked( + /// + public static ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -35556,66 +34170,104 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValueFromRaw - : IFromRawJson +class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactorFromRaw + : IFromRawJson { /// - public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue FromRawUnchecked( + public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor FromRawUnchecked( IReadOnlyDictionary rawData - ) => CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue.FromRawUnchecked(rawData); + ) => + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor.FromRawUnchecked( + rawData + ); } -[JsonConverter(typeof(CumulativeGroupedBulkPriceTypeConverter))] -public enum CumulativeGroupedBulkPriceType +/// +/// Configuration for a single tier entry with business logic +/// +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier, + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTierFromRaw + >) +)] +public sealed record class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + : JsonModel { - UsagePrice, - FixedPrice, - CompositePrice, -} + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } -sealed class CumulativeGroupedBulkPriceTypeConverter : JsonConverter -{ - public override CumulativeGroupedBulkPriceType Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + public required string UnitAmount { - return JsonSerializer.Deserialize(ref reader, options) switch + get { - "usage_price" => CumulativeGroupedBulkPriceType.UsagePrice, - "fixed_price" => CumulativeGroupedBulkPriceType.FixedPrice, - "composite_price" => CumulativeGroupedBulkPriceType.CompositePrice, - _ => (CumulativeGroupedBulkPriceType)(-1), - }; + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } } - public override void Write( - Utf8JsonWriter writer, - CumulativeGroupedBulkPriceType value, - JsonSerializerOptions options + /// + public override void Validate() + { + _ = this.TierLowerBound; + _ = this.UnitAmount; + } + + public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier() { } + + public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier( + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + ) + : base(scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier) { } + + public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier( + IReadOnlyDictionary rawData ) { - JsonSerializer.Serialize( - writer, - value switch - { - CumulativeGroupedBulkPriceType.UsagePrice => "usage_price", - CumulativeGroupedBulkPriceType.FixedPrice => "fixed_price", - CumulativeGroupedBulkPriceType.CompositePrice => "composite_price", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -[JsonConverter( - typeof(JsonModelConverter) -)] -public sealed record class CumulativeGroupedAllocation : JsonModel +class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTierFromRaw + : IFromRawJson +{ + /// + public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier.FromRawUnchecked( + rawData + ); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class CumulativeGroupedBulk : JsonModel { public required string ID { @@ -35649,42 +34301,42 @@ public required BillingCycleConfiguration BillingCycleConfiguration init { this._rawData.Set("billing_cycle_configuration", value); } } - public required ApiEnum BillingMode + public required ApiEnum BillingMode { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("billing_mode"); + return this._rawData.GetNotNullClass>( + "billing_mode" + ); } init { this._rawData.Set("billing_mode", value); } } - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } init { this._rawData.Set("cadence", value); } } - public required IReadOnlyList? CompositePriceFilters + public required IReadOnlyList? CompositePriceFilters { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("composite_price_filters"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "composite_price_filters", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -35701,12 +34353,12 @@ public required double? ConversionRate init { this._rawData.Set("conversion_rate", value); } } - public required CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + public required CumulativeGroupedBulkConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -35734,18 +34386,18 @@ public required Allocation? CreditAllocation } /// - /// Configuration for cumulative_grouped_allocation pricing + /// Configuration for cumulative_grouped_bulk pricing /// - public required CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required CumulativeGroupedBulkCumulativeGroupedBulkConfig CumulativeGroupedBulkConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "cumulative_grouped_allocation_config" + return this._rawData.GetNotNullClass( + "cumulative_grouped_bulk_config" ); } - init { this._rawData.Set("cumulative_grouped_allocation_config", value); } + init { this._rawData.Set("cumulative_grouped_bulk_config", value); } } public required string Currency @@ -35913,14 +34565,14 @@ public required long? PlanPhaseOrder init { this._rawData.Set("plan_phase_order", value); } } - public required ApiEnum PriceType + public required ApiEnum PriceType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("price_type"); + return this._rawData.GetNotNullClass>( + "price_type" + ); } init { this._rawData.Set("price_type", value); } } @@ -35967,7 +34619,7 @@ public override void Validate() this.ConversionRateConfig?.Validate(); _ = this.CreatedAt; this.CreditAllocation?.Validate(); - this.CumulativeGroupedAllocationConfig.Validate(); + this.CumulativeGroupedBulkConfig.Validate(); _ = this.Currency; this.Discount?.Validate(); _ = this.ExternalPriceID; @@ -35982,7 +34634,7 @@ public override void Validate() if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + JsonSerializer.SerializeToElement("cumulative_grouped_bulk") ) ) { @@ -35998,25 +34650,25 @@ public override void Validate() [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public CumulativeGroupedAllocation() + public CumulativeGroupedBulk() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_bulk"); } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) - : base(cumulativeGroupedAllocation) { } + public CumulativeGroupedBulk(CumulativeGroupedBulk cumulativeGroupedBulk) + : base(cumulativeGroupedBulk) { } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) + public CumulativeGroupedBulk(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_bulk"); } #pragma warning disable CS8618 @@ -36024,14 +34676,14 @@ public CumulativeGroupedAllocation(IReadOnlyDictionary rawD "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] [SetsRequiredMembers] - CumulativeGroupedAllocation(FrozenDictionary rawData) + CumulativeGroupedBulk(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static CumulativeGroupedAllocation FromRawUnchecked( + /// + public static CumulativeGroupedBulk FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -36039,25 +34691,25 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationFromRaw : IFromRawJson +class CumulativeGroupedBulkFromRaw : IFromRawJson { /// - public CumulativeGroupedAllocation FromRawUnchecked( + public CumulativeGroupedBulk FromRawUnchecked( IReadOnlyDictionary rawData - ) => CumulativeGroupedAllocation.FromRawUnchecked(rawData); + ) => CumulativeGroupedBulk.FromRawUnchecked(rawData); } -[JsonConverter(typeof(CumulativeGroupedAllocationBillingModeConverter))] -public enum CumulativeGroupedAllocationBillingMode +[JsonConverter(typeof(CumulativeGroupedBulkBillingModeConverter))] +public enum CumulativeGroupedBulkBillingMode { InAdvance, InArrear, } -sealed class CumulativeGroupedAllocationBillingModeConverter - : JsonConverter +sealed class CumulativeGroupedBulkBillingModeConverter + : JsonConverter { - public override CumulativeGroupedAllocationBillingMode Read( + public override CumulativeGroupedBulkBillingMode Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -36065,15 +34717,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "in_advance" => CumulativeGroupedAllocationBillingMode.InAdvance, - "in_arrear" => CumulativeGroupedAllocationBillingMode.InArrear, - _ => (CumulativeGroupedAllocationBillingMode)(-1), + "in_advance" => CumulativeGroupedBulkBillingMode.InAdvance, + "in_arrear" => CumulativeGroupedBulkBillingMode.InArrear, + _ => (CumulativeGroupedBulkBillingMode)(-1), }; } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedAllocationBillingMode value, + CumulativeGroupedBulkBillingMode value, JsonSerializerOptions options ) { @@ -36081,8 +34733,8 @@ JsonSerializerOptions options writer, value switch { - CumulativeGroupedAllocationBillingMode.InAdvance => "in_advance", - CumulativeGroupedAllocationBillingMode.InArrear => "in_arrear", + CumulativeGroupedBulkBillingMode.InAdvance => "in_advance", + CumulativeGroupedBulkBillingMode.InArrear => "in_arrear", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -36092,8 +34744,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] -public enum CumulativeGroupedAllocationCadence +[JsonConverter(typeof(CumulativeGroupedBulkCadenceConverter))] +public enum CumulativeGroupedBulkCadence { OneTime, Monthly, @@ -36103,10 +34755,9 @@ public enum CumulativeGroupedAllocationCadence Custom, } -sealed class CumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class CumulativeGroupedBulkCadenceConverter : JsonConverter { - public override CumulativeGroupedAllocationCadence Read( + public override CumulativeGroupedBulkCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -36114,19 +34765,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "one_time" => CumulativeGroupedAllocationCadence.OneTime, - "monthly" => CumulativeGroupedAllocationCadence.Monthly, - "quarterly" => CumulativeGroupedAllocationCadence.Quarterly, - "semi_annual" => CumulativeGroupedAllocationCadence.SemiAnnual, - "annual" => CumulativeGroupedAllocationCadence.Annual, - "custom" => CumulativeGroupedAllocationCadence.Custom, - _ => (CumulativeGroupedAllocationCadence)(-1), + "one_time" => CumulativeGroupedBulkCadence.OneTime, + "monthly" => CumulativeGroupedBulkCadence.Monthly, + "quarterly" => CumulativeGroupedBulkCadence.Quarterly, + "semi_annual" => CumulativeGroupedBulkCadence.SemiAnnual, + "annual" => CumulativeGroupedBulkCadence.Annual, + "custom" => CumulativeGroupedBulkCadence.Custom, + _ => (CumulativeGroupedBulkCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedAllocationCadence value, + CumulativeGroupedBulkCadence value, JsonSerializerOptions options ) { @@ -36134,12 +34785,12 @@ JsonSerializerOptions options writer, value switch { - CumulativeGroupedAllocationCadence.OneTime => "one_time", - CumulativeGroupedAllocationCadence.Monthly => "monthly", - CumulativeGroupedAllocationCadence.Quarterly => "quarterly", - CumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", - CumulativeGroupedAllocationCadence.Annual => "annual", - CumulativeGroupedAllocationCadence.Custom => "custom", + CumulativeGroupedBulkCadence.OneTime => "one_time", + CumulativeGroupedBulkCadence.Monthly => "monthly", + CumulativeGroupedBulkCadence.Quarterly => "quarterly", + CumulativeGroupedBulkCadence.SemiAnnual => "semi_annual", + CumulativeGroupedBulkCadence.Annual => "annual", + CumulativeGroupedBulkCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -36151,22 +34802,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - CumulativeGroupedAllocationCompositePriceFilter, - CumulativeGroupedAllocationCompositePriceFilterFromRaw + CumulativeGroupedBulkCompositePriceFilter, + CumulativeGroupedBulkCompositePriceFilterFromRaw >) )] -public sealed record class CumulativeGroupedAllocationCompositePriceFilter : JsonModel +public sealed record class CumulativeGroupedBulkCompositePriceFilter : JsonModel { /// /// The property of the price to filter on. /// - public required ApiEnum Field + public required ApiEnum Field { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("field"); } init { this._rawData.Set("field", value); } @@ -36175,16 +34826,13 @@ public required ApiEnum /// Should prices that match the filter be included or excluded. /// - public required ApiEnum< - string, - CumulativeGroupedAllocationCompositePriceFilterOperator - > Operator + public required ApiEnum Operator { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("operator"); } init { this._rawData.Set("operator", value); } @@ -36217,14 +34865,14 @@ public override void Validate() _ = this.Values; } - public CumulativeGroupedAllocationCompositePriceFilter() { } + public CumulativeGroupedBulkCompositePriceFilter() { } - public CumulativeGroupedAllocationCompositePriceFilter( - CumulativeGroupedAllocationCompositePriceFilter cumulativeGroupedAllocationCompositePriceFilter + public CumulativeGroupedBulkCompositePriceFilter( + CumulativeGroupedBulkCompositePriceFilter cumulativeGroupedBulkCompositePriceFilter ) - : base(cumulativeGroupedAllocationCompositePriceFilter) { } + : base(cumulativeGroupedBulkCompositePriceFilter) { } - public CumulativeGroupedAllocationCompositePriceFilter( + public CumulativeGroupedBulkCompositePriceFilter( IReadOnlyDictionary rawData ) { @@ -36233,14 +34881,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocationCompositePriceFilter(FrozenDictionary rawData) + CumulativeGroupedBulkCompositePriceFilter(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static CumulativeGroupedAllocationCompositePriceFilter FromRawUnchecked( + /// + public static CumulativeGroupedBulkCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -36248,20 +34896,20 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationCompositePriceFilterFromRaw - : IFromRawJson +class CumulativeGroupedBulkCompositePriceFilterFromRaw + : IFromRawJson { /// - public CumulativeGroupedAllocationCompositePriceFilter FromRawUnchecked( + public CumulativeGroupedBulkCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => CumulativeGroupedAllocationCompositePriceFilter.FromRawUnchecked(rawData); + ) => CumulativeGroupedBulkCompositePriceFilter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(CumulativeGroupedAllocationCompositePriceFilterFieldConverter))] -public enum CumulativeGroupedAllocationCompositePriceFilterField +[JsonConverter(typeof(CumulativeGroupedBulkCompositePriceFilterFieldConverter))] +public enum CumulativeGroupedBulkCompositePriceFilterField { PriceID, ItemID, @@ -36270,10 +34918,10 @@ public enum CumulativeGroupedAllocationCompositePriceFilterField PricingUnitID, } -sealed class CumulativeGroupedAllocationCompositePriceFilterFieldConverter - : JsonConverter +sealed class CumulativeGroupedBulkCompositePriceFilterFieldConverter + : JsonConverter { - public override CumulativeGroupedAllocationCompositePriceFilterField Read( + public override CumulativeGroupedBulkCompositePriceFilterField Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -36281,18 +34929,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "price_id" => CumulativeGroupedAllocationCompositePriceFilterField.PriceID, - "item_id" => CumulativeGroupedAllocationCompositePriceFilterField.ItemID, - "price_type" => CumulativeGroupedAllocationCompositePriceFilterField.PriceType, - "currency" => CumulativeGroupedAllocationCompositePriceFilterField.Currency, - "pricing_unit_id" => CumulativeGroupedAllocationCompositePriceFilterField.PricingUnitID, - _ => (CumulativeGroupedAllocationCompositePriceFilterField)(-1), + "price_id" => CumulativeGroupedBulkCompositePriceFilterField.PriceID, + "item_id" => CumulativeGroupedBulkCompositePriceFilterField.ItemID, + "price_type" => CumulativeGroupedBulkCompositePriceFilterField.PriceType, + "currency" => CumulativeGroupedBulkCompositePriceFilterField.Currency, + "pricing_unit_id" => CumulativeGroupedBulkCompositePriceFilterField.PricingUnitID, + _ => (CumulativeGroupedBulkCompositePriceFilterField)(-1), }; } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedAllocationCompositePriceFilterField value, + CumulativeGroupedBulkCompositePriceFilterField value, JsonSerializerOptions options ) { @@ -36300,12 +34948,11 @@ JsonSerializerOptions options writer, value switch { - CumulativeGroupedAllocationCompositePriceFilterField.PriceID => "price_id", - CumulativeGroupedAllocationCompositePriceFilterField.ItemID => "item_id", - CumulativeGroupedAllocationCompositePriceFilterField.PriceType => "price_type", - CumulativeGroupedAllocationCompositePriceFilterField.Currency => "currency", - CumulativeGroupedAllocationCompositePriceFilterField.PricingUnitID => - "pricing_unit_id", + CumulativeGroupedBulkCompositePriceFilterField.PriceID => "price_id", + CumulativeGroupedBulkCompositePriceFilterField.ItemID => "item_id", + CumulativeGroupedBulkCompositePriceFilterField.PriceType => "price_type", + CumulativeGroupedBulkCompositePriceFilterField.Currency => "currency", + CumulativeGroupedBulkCompositePriceFilterField.PricingUnitID => "pricing_unit_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -36318,17 +34965,17 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(CumulativeGroupedAllocationCompositePriceFilterOperatorConverter))] -public enum CumulativeGroupedAllocationCompositePriceFilterOperator +[JsonConverter(typeof(CumulativeGroupedBulkCompositePriceFilterOperatorConverter))] +public enum CumulativeGroupedBulkCompositePriceFilterOperator { Includes, Excludes, } -sealed class CumulativeGroupedAllocationCompositePriceFilterOperatorConverter - : JsonConverter +sealed class CumulativeGroupedBulkCompositePriceFilterOperatorConverter + : JsonConverter { - public override CumulativeGroupedAllocationCompositePriceFilterOperator Read( + public override CumulativeGroupedBulkCompositePriceFilterOperator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -36336,15 +34983,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, - "excludes" => CumulativeGroupedAllocationCompositePriceFilterOperator.Excludes, - _ => (CumulativeGroupedAllocationCompositePriceFilterOperator)(-1), + "includes" => CumulativeGroupedBulkCompositePriceFilterOperator.Includes, + "excludes" => CumulativeGroupedBulkCompositePriceFilterOperator.Excludes, + _ => (CumulativeGroupedBulkCompositePriceFilterOperator)(-1), }; } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedAllocationCompositePriceFilterOperator value, + CumulativeGroupedBulkCompositePriceFilterOperator value, JsonSerializerOptions options ) { @@ -36352,8 +34999,8 @@ JsonSerializerOptions options writer, value switch { - CumulativeGroupedAllocationCompositePriceFilterOperator.Includes => "includes", - CumulativeGroupedAllocationCompositePriceFilterOperator.Excludes => "excludes", + CumulativeGroupedBulkCompositePriceFilterOperator.Includes => "includes", + CumulativeGroupedBulkCompositePriceFilterOperator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -36363,8 +35010,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(CumulativeGroupedAllocationConversionRateConfigConverter))] -public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(CumulativeGroupedBulkConversionRateConfigConverter))] +public record class CumulativeGroupedBulkConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -36381,7 +35028,7 @@ public JsonElement Json } } - public CumulativeGroupedAllocationConversionRateConfig( + public CumulativeGroupedBulkConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -36390,7 +35037,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig( + public CumulativeGroupedBulkConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -36399,7 +35046,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public CumulativeGroupedBulkConversionRateConfig(JsonElement element) { this._element = element; } @@ -36481,7 +35128,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of CumulativeGroupedBulkConversionRateConfig" ); } } @@ -36517,16 +35164,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of CumulativeGroupedBulkConversionRateConfig" ), }; } - public static implicit operator CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator CumulativeGroupedBulkConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator CumulativeGroupedBulkConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -36545,13 +35192,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of CumulativeGroupedBulkConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) + public virtual bool Equals(CumulativeGroupedBulkConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -36565,10 +35212,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class CumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter +sealed class CumulativeGroupedBulkConversionRateConfigConverter + : JsonConverter { - public override CumulativeGroupedAllocationConversionRateConfig? Read( + public override CumulativeGroupedBulkConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -36633,14 +35280,14 @@ JsonSerializerOptions options } default: { - return new CumulativeGroupedAllocationConversionRateConfig(element); + return new CumulativeGroupedBulkConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedAllocationConversionRateConfig value, + CumulativeGroupedBulkConversionRateConfig value, JsonSerializerOptions options ) { @@ -36649,44 +35296,110 @@ JsonSerializerOptions options } /// -/// Configuration for cumulative_grouped_allocation pricing +/// Configuration for cumulative_grouped_bulk pricing /// [JsonConverter( typeof(JsonModelConverter< - CumulativeGroupedAllocationConfig, - CumulativeGroupedAllocationConfigFromRaw + CumulativeGroupedBulkCumulativeGroupedBulkConfig, + CumulativeGroupedBulkCumulativeGroupedBulkConfigFromRaw >) )] -public sealed record class CumulativeGroupedAllocationConfig : JsonModel +public sealed record class CumulativeGroupedBulkCumulativeGroupedBulkConfig : JsonModel { /// - /// The overall allocation across all groups + /// Each tier lower bound must have the same group of values. /// - public required string CumulativeAllocation + public required IReadOnlyList DimensionValues { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("cumulative_allocation"); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("dimension_values"); + } + init + { + this._rawData.Set< + ImmutableArray + >("dimension_values", ImmutableArray.ToImmutableArray(value)); } - init { this._rawData.Set("cumulative_allocation", value); } } - /// - /// The allocation per individual group - /// - public required string GroupAllocation + public required string Group { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group_allocation"); + return this._rawData.GetNotNullClass("group"); } - init { this._rawData.Set("group_allocation", value); } + init { this._rawData.Set("group", value); } + } + + /// + public override void Validate() + { + foreach (var item in this.DimensionValues) + { + item.Validate(); + } + _ = this.Group; + } + + public CumulativeGroupedBulkCumulativeGroupedBulkConfig() { } + + public CumulativeGroupedBulkCumulativeGroupedBulkConfig( + CumulativeGroupedBulkCumulativeGroupedBulkConfig cumulativeGroupedBulkCumulativeGroupedBulkConfig + ) + : base(cumulativeGroupedBulkCumulativeGroupedBulkConfig) { } + + public CumulativeGroupedBulkCumulativeGroupedBulkConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); } +#pragma warning disable CS8618 + [SetsRequiredMembers] + CumulativeGroupedBulkCumulativeGroupedBulkConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CumulativeGroupedBulkCumulativeGroupedBulkConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CumulativeGroupedBulkCumulativeGroupedBulkConfigFromRaw + : IFromRawJson +{ + /// + public CumulativeGroupedBulkCumulativeGroupedBulkConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedBulkCumulativeGroupedBulkConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a dimension value entry +/// +[JsonConverter( + typeof(JsonModelConverter< + CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue, + CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValueFromRaw + >) +)] +public sealed record class CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + : JsonModel +{ /// - /// The event property used to group usage before applying allocations + /// Grouping key value /// public required string GroupingKey { @@ -36699,7 +35412,20 @@ public required string GroupingKey } /// - /// The amount to charge for each unit outside of the allocation + /// Tier lower bound + /// + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + /// Unit amount for this combination /// public required string UnitAmount { @@ -36714,34 +35440,37 @@ public required string UnitAmount /// public override void Validate() { - _ = this.CumulativeAllocation; - _ = this.GroupAllocation; _ = this.GroupingKey; + _ = this.TierLowerBound; _ = this.UnitAmount; } - public CumulativeGroupedAllocationConfig() { } + public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue() { } - public CumulativeGroupedAllocationConfig( - CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( + CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue cumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue ) - : base(cumulativeGroupedAllocationConfig) { } + : base(cumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue) { } - public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) + public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocationConfig(FrozenDictionary rawData) + CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -36749,26 +35478,26 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationConfigFromRaw : IFromRawJson +class CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValueFromRaw + : IFromRawJson { /// - public CumulativeGroupedAllocationConfig FromRawUnchecked( + public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue FromRawUnchecked( IReadOnlyDictionary rawData - ) => CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); + ) => CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue.FromRawUnchecked(rawData); } -[JsonConverter(typeof(CumulativeGroupedAllocationPriceTypeConverter))] -public enum CumulativeGroupedAllocationPriceType +[JsonConverter(typeof(CumulativeGroupedBulkPriceTypeConverter))] +public enum CumulativeGroupedBulkPriceType { UsagePrice, FixedPrice, CompositePrice, } -sealed class CumulativeGroupedAllocationPriceTypeConverter - : JsonConverter +sealed class CumulativeGroupedBulkPriceTypeConverter : JsonConverter { - public override CumulativeGroupedAllocationPriceType Read( + public override CumulativeGroupedBulkPriceType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -36776,16 +35505,16 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "usage_price" => CumulativeGroupedAllocationPriceType.UsagePrice, - "fixed_price" => CumulativeGroupedAllocationPriceType.FixedPrice, - "composite_price" => CumulativeGroupedAllocationPriceType.CompositePrice, - _ => (CumulativeGroupedAllocationPriceType)(-1), + "usage_price" => CumulativeGroupedBulkPriceType.UsagePrice, + "fixed_price" => CumulativeGroupedBulkPriceType.FixedPrice, + "composite_price" => CumulativeGroupedBulkPriceType.CompositePrice, + _ => (CumulativeGroupedBulkPriceType)(-1), }; } public override void Write( Utf8JsonWriter writer, - CumulativeGroupedAllocationPriceType value, + CumulativeGroupedBulkPriceType value, JsonSerializerOptions options ) { @@ -36793,9 +35522,9 @@ JsonSerializerOptions options writer, value switch { - CumulativeGroupedAllocationPriceType.UsagePrice => "usage_price", - CumulativeGroupedAllocationPriceType.FixedPrice => "fixed_price", - CumulativeGroupedAllocationPriceType.CompositePrice => "composite_price", + CumulativeGroupedBulkPriceType.UsagePrice => "usage_price", + CumulativeGroupedBulkPriceType.FixedPrice => "fixed_price", + CumulativeGroupedBulkPriceType.CompositePrice => "composite_price", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -36805,8 +35534,10 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class PriceMinimum : JsonModel +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class CumulativeGroupedAllocation : JsonModel { public required string ID { @@ -36840,40 +35571,42 @@ public required BillingCycleConfiguration BillingCycleConfiguration init { this._rawData.Set("billing_cycle_configuration", value); } } - public required ApiEnum BillingMode + public required ApiEnum BillingMode { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( - "billing_mode" - ); + return this._rawData.GetNotNullClass< + ApiEnum + >("billing_mode"); } init { this._rawData.Set("billing_mode", value); } } - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>("cadence"); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); } init { this._rawData.Set("cadence", value); } } - public required IReadOnlyList? CompositePriceFilters + public required IReadOnlyList? CompositePriceFilters { get { this._rawData.Freeze(); return this._rawData.GetNullableStruct< - ImmutableArray + ImmutableArray >("composite_price_filters"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "composite_price_filters", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -36890,12 +35623,12 @@ public required double? ConversionRate init { this._rawData.Set("conversion_rate", value); } } - public required PriceMinimumConversionRateConfig? ConversionRateConfig + public required CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -36922,6 +35655,21 @@ public required Allocation? CreditAllocation init { this._rawData.Set("credit_allocation", value); } } + /// + /// Configuration for cumulative_grouped_allocation pricing + /// + public required CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "cumulative_grouped_allocation_config" + ); + } + init { this._rawData.Set("cumulative_grouped_allocation_config", value); } + } + public required string Currency { get @@ -37054,19 +35802,6 @@ public required string? MinimumAmount init { this._rawData.Set("minimum_amount", value); } } - /// - /// Configuration for minimum pricing - /// - public required MinimumConfig MinimumConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_config"); - } - init { this._rawData.Set("minimum_config", value); } - } - /// /// The pricing model type /// @@ -37100,14 +35835,14 @@ public required long? PlanPhaseOrder init { this._rawData.Set("plan_phase_order", value); } } - public required ApiEnum PriceType + public required ApiEnum PriceType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( - "price_type" - ); + return this._rawData.GetNotNullClass< + ApiEnum + >("price_type"); } init { this._rawData.Set("price_type", value); } } @@ -37154,6 +35889,7 @@ public override void Validate() this.ConversionRateConfig?.Validate(); _ = this.CreatedAt; this.CreditAllocation?.Validate(); + this.CumulativeGroupedAllocationConfig.Validate(); _ = this.Currency; this.Discount?.Validate(); _ = this.ExternalPriceID; @@ -37165,8 +35901,12 @@ public override void Validate() _ = this.Metadata; this.Minimum?.Validate(); _ = this.MinimumAmount; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -37180,25 +35920,25 @@ public override void Validate() [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public PriceMinimum() + public CumulativeGroupedAllocation() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public PriceMinimum(PriceMinimum priceMinimum) - : base(priceMinimum) { } + public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) + : base(cumulativeGroupedAllocation) { } [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public PriceMinimum(IReadOnlyDictionary rawData) + public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } #pragma warning disable CS8618 @@ -37206,36 +35946,40 @@ public PriceMinimum(IReadOnlyDictionary rawData) "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] [SetsRequiredMembers] - PriceMinimum(FrozenDictionary rawData) + CumulativeGroupedAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static PriceMinimum FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static CumulativeGroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PriceMinimumFromRaw : IFromRawJson +class CumulativeGroupedAllocationFromRaw : IFromRawJson { /// - public PriceMinimum FromRawUnchecked(IReadOnlyDictionary rawData) => - PriceMinimum.FromRawUnchecked(rawData); + public CumulativeGroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedAllocation.FromRawUnchecked(rawData); } -[JsonConverter(typeof(PriceMinimumBillingModeConverter))] -public enum PriceMinimumBillingMode +[JsonConverter(typeof(CumulativeGroupedAllocationBillingModeConverter))] +public enum CumulativeGroupedAllocationBillingMode { InAdvance, InArrear, } -sealed class PriceMinimumBillingModeConverter : JsonConverter +sealed class CumulativeGroupedAllocationBillingModeConverter + : JsonConverter { - public override PriceMinimumBillingMode Read( + public override CumulativeGroupedAllocationBillingMode Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -37243,15 +35987,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "in_advance" => PriceMinimumBillingMode.InAdvance, - "in_arrear" => PriceMinimumBillingMode.InArrear, - _ => (PriceMinimumBillingMode)(-1), + "in_advance" => CumulativeGroupedAllocationBillingMode.InAdvance, + "in_arrear" => CumulativeGroupedAllocationBillingMode.InArrear, + _ => (CumulativeGroupedAllocationBillingMode)(-1), }; } public override void Write( Utf8JsonWriter writer, - PriceMinimumBillingMode value, + CumulativeGroupedAllocationBillingMode value, JsonSerializerOptions options ) { @@ -37259,8 +36003,8 @@ JsonSerializerOptions options writer, value switch { - PriceMinimumBillingMode.InAdvance => "in_advance", - PriceMinimumBillingMode.InArrear => "in_arrear", + CumulativeGroupedAllocationBillingMode.InAdvance => "in_advance", + CumulativeGroupedAllocationBillingMode.InArrear => "in_arrear", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -37270,8 +36014,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(PriceMinimumCadenceConverter))] -public enum PriceMinimumCadence +[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] +public enum CumulativeGroupedAllocationCadence { OneTime, Monthly, @@ -37281,9 +36025,10 @@ public enum PriceMinimumCadence Custom, } -sealed class PriceMinimumCadenceConverter : JsonConverter +sealed class CumulativeGroupedAllocationCadenceConverter + : JsonConverter { - public override PriceMinimumCadence Read( + public override CumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -37291,19 +36036,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "one_time" => PriceMinimumCadence.OneTime, - "monthly" => PriceMinimumCadence.Monthly, - "quarterly" => PriceMinimumCadence.Quarterly, - "semi_annual" => PriceMinimumCadence.SemiAnnual, - "annual" => PriceMinimumCadence.Annual, - "custom" => PriceMinimumCadence.Custom, - _ => (PriceMinimumCadence)(-1), + "one_time" => CumulativeGroupedAllocationCadence.OneTime, + "monthly" => CumulativeGroupedAllocationCadence.Monthly, + "quarterly" => CumulativeGroupedAllocationCadence.Quarterly, + "semi_annual" => CumulativeGroupedAllocationCadence.SemiAnnual, + "annual" => CumulativeGroupedAllocationCadence.Annual, + "custom" => CumulativeGroupedAllocationCadence.Custom, + _ => (CumulativeGroupedAllocationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - PriceMinimumCadence value, + CumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -37311,12 +36056,12 @@ JsonSerializerOptions options writer, value switch { - PriceMinimumCadence.OneTime => "one_time", - PriceMinimumCadence.Monthly => "monthly", - PriceMinimumCadence.Quarterly => "quarterly", - PriceMinimumCadence.SemiAnnual => "semi_annual", - PriceMinimumCadence.Annual => "annual", - PriceMinimumCadence.Custom => "custom", + CumulativeGroupedAllocationCadence.OneTime => "one_time", + CumulativeGroupedAllocationCadence.Monthly => "monthly", + CumulativeGroupedAllocationCadence.Quarterly => "quarterly", + CumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", + CumulativeGroupedAllocationCadence.Annual => "annual", + CumulativeGroupedAllocationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -37328,22 +36073,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - PriceMinimumCompositePriceFilter, - PriceMinimumCompositePriceFilterFromRaw + CumulativeGroupedAllocationCompositePriceFilter, + CumulativeGroupedAllocationCompositePriceFilterFromRaw >) )] -public sealed record class PriceMinimumCompositePriceFilter : JsonModel +public sealed record class CumulativeGroupedAllocationCompositePriceFilter : JsonModel { /// /// The property of the price to filter on. /// - public required ApiEnum Field + public required ApiEnum Field { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("field"); } init { this._rawData.Set("field", value); } @@ -37352,13 +36097,16 @@ public required ApiEnum Field /// /// Should prices that match the filter be included or excluded. /// - public required ApiEnum Operator + public required ApiEnum< + string, + CumulativeGroupedAllocationCompositePriceFilterOperator + > Operator { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("operator"); } init { this._rawData.Set("operator", value); } @@ -37391,28 +36139,30 @@ public override void Validate() _ = this.Values; } - public PriceMinimumCompositePriceFilter() { } + public CumulativeGroupedAllocationCompositePriceFilter() { } - public PriceMinimumCompositePriceFilter( - PriceMinimumCompositePriceFilter priceMinimumCompositePriceFilter + public CumulativeGroupedAllocationCompositePriceFilter( + CumulativeGroupedAllocationCompositePriceFilter cumulativeGroupedAllocationCompositePriceFilter ) - : base(priceMinimumCompositePriceFilter) { } + : base(cumulativeGroupedAllocationCompositePriceFilter) { } - public PriceMinimumCompositePriceFilter(IReadOnlyDictionary rawData) + public CumulativeGroupedAllocationCompositePriceFilter( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - PriceMinimumCompositePriceFilter(FrozenDictionary rawData) + CumulativeGroupedAllocationCompositePriceFilter(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static PriceMinimumCompositePriceFilter FromRawUnchecked( + /// + public static CumulativeGroupedAllocationCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -37420,19 +36170,20 @@ IReadOnlyDictionary rawData } } -class PriceMinimumCompositePriceFilterFromRaw : IFromRawJson +class CumulativeGroupedAllocationCompositePriceFilterFromRaw + : IFromRawJson { /// - public PriceMinimumCompositePriceFilter FromRawUnchecked( + public CumulativeGroupedAllocationCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => PriceMinimumCompositePriceFilter.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocationCompositePriceFilter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(PriceMinimumCompositePriceFilterFieldConverter))] -public enum PriceMinimumCompositePriceFilterField +[JsonConverter(typeof(CumulativeGroupedAllocationCompositePriceFilterFieldConverter))] +public enum CumulativeGroupedAllocationCompositePriceFilterField { PriceID, ItemID, @@ -37441,10 +36192,10 @@ public enum PriceMinimumCompositePriceFilterField PricingUnitID, } -sealed class PriceMinimumCompositePriceFilterFieldConverter - : JsonConverter +sealed class CumulativeGroupedAllocationCompositePriceFilterFieldConverter + : JsonConverter { - public override PriceMinimumCompositePriceFilterField Read( + public override CumulativeGroupedAllocationCompositePriceFilterField Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -37452,18 +36203,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "price_id" => PriceMinimumCompositePriceFilterField.PriceID, - "item_id" => PriceMinimumCompositePriceFilterField.ItemID, - "price_type" => PriceMinimumCompositePriceFilterField.PriceType, - "currency" => PriceMinimumCompositePriceFilterField.Currency, - "pricing_unit_id" => PriceMinimumCompositePriceFilterField.PricingUnitID, - _ => (PriceMinimumCompositePriceFilterField)(-1), + "price_id" => CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + "item_id" => CumulativeGroupedAllocationCompositePriceFilterField.ItemID, + "price_type" => CumulativeGroupedAllocationCompositePriceFilterField.PriceType, + "currency" => CumulativeGroupedAllocationCompositePriceFilterField.Currency, + "pricing_unit_id" => CumulativeGroupedAllocationCompositePriceFilterField.PricingUnitID, + _ => (CumulativeGroupedAllocationCompositePriceFilterField)(-1), }; } public override void Write( Utf8JsonWriter writer, - PriceMinimumCompositePriceFilterField value, + CumulativeGroupedAllocationCompositePriceFilterField value, JsonSerializerOptions options ) { @@ -37471,11 +36222,12 @@ JsonSerializerOptions options writer, value switch { - PriceMinimumCompositePriceFilterField.PriceID => "price_id", - PriceMinimumCompositePriceFilterField.ItemID => "item_id", - PriceMinimumCompositePriceFilterField.PriceType => "price_type", - PriceMinimumCompositePriceFilterField.Currency => "currency", - PriceMinimumCompositePriceFilterField.PricingUnitID => "pricing_unit_id", + CumulativeGroupedAllocationCompositePriceFilterField.PriceID => "price_id", + CumulativeGroupedAllocationCompositePriceFilterField.ItemID => "item_id", + CumulativeGroupedAllocationCompositePriceFilterField.PriceType => "price_type", + CumulativeGroupedAllocationCompositePriceFilterField.Currency => "currency", + CumulativeGroupedAllocationCompositePriceFilterField.PricingUnitID => + "pricing_unit_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -37488,17 +36240,17 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(PriceMinimumCompositePriceFilterOperatorConverter))] -public enum PriceMinimumCompositePriceFilterOperator +[JsonConverter(typeof(CumulativeGroupedAllocationCompositePriceFilterOperatorConverter))] +public enum CumulativeGroupedAllocationCompositePriceFilterOperator { Includes, Excludes, } -sealed class PriceMinimumCompositePriceFilterOperatorConverter - : JsonConverter +sealed class CumulativeGroupedAllocationCompositePriceFilterOperatorConverter + : JsonConverter { - public override PriceMinimumCompositePriceFilterOperator Read( + public override CumulativeGroupedAllocationCompositePriceFilterOperator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -37506,15 +36258,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => PriceMinimumCompositePriceFilterOperator.Includes, - "excludes" => PriceMinimumCompositePriceFilterOperator.Excludes, - _ => (PriceMinimumCompositePriceFilterOperator)(-1), + "includes" => CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, + "excludes" => CumulativeGroupedAllocationCompositePriceFilterOperator.Excludes, + _ => (CumulativeGroupedAllocationCompositePriceFilterOperator)(-1), }; } public override void Write( Utf8JsonWriter writer, - PriceMinimumCompositePriceFilterOperator value, + CumulativeGroupedAllocationCompositePriceFilterOperator value, JsonSerializerOptions options ) { @@ -37522,8 +36274,8 @@ JsonSerializerOptions options writer, value switch { - PriceMinimumCompositePriceFilterOperator.Includes => "includes", - PriceMinimumCompositePriceFilterOperator.Excludes => "excludes", + CumulativeGroupedAllocationCompositePriceFilterOperator.Includes => "includes", + CumulativeGroupedAllocationCompositePriceFilterOperator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -37533,8 +36285,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(PriceMinimumConversionRateConfigConverter))] -public record class PriceMinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(CumulativeGroupedAllocationConversionRateConfigConverter))] +public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -37551,7 +36303,7 @@ public JsonElement Json } } - public PriceMinimumConversionRateConfig( + public CumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -37560,7 +36312,7 @@ public PriceMinimumConversionRateConfig( this._element = element; } - public PriceMinimumConversionRateConfig( + public CumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -37569,7 +36321,7 @@ public PriceMinimumConversionRateConfig( this._element = element; } - public PriceMinimumConversionRateConfig(JsonElement element) + public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -37651,7 +36403,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PriceMinimumConversionRateConfig" + "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" ); } } @@ -37687,16 +36439,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of PriceMinimumConversionRateConfig" + "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator PriceMinimumConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator PriceMinimumConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -37715,13 +36467,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of PriceMinimumConversionRateConfig" + "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PriceMinimumConversionRateConfig? other) + public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -37735,10 +36487,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class PriceMinimumConversionRateConfigConverter - : JsonConverter +sealed class CumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override PriceMinimumConversionRateConfig? Read( + public override CumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -37803,14 +36555,14 @@ JsonSerializerOptions options } default: { - return new PriceMinimumConversionRateConfig(element); + return new CumulativeGroupedAllocationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - PriceMinimumConversionRateConfig value, + CumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -37819,102 +36571,126 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for cumulative_grouped_allocation pricing /// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class MinimumConfig : JsonModel +[JsonConverter( + typeof(JsonModelConverter< + CumulativeGroupedAllocationConfig, + CumulativeGroupedAllocationConfigFromRaw + >) +)] +public sealed record class CumulativeGroupedAllocationConfig : JsonModel { /// - /// The minimum amount to apply + /// The overall allocation across all groups /// - public required string MinimumAmount + public required string CumulativeAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNotNullClass("cumulative_allocation"); } - init { this._rawData.Set("minimum_amount", value); } + init { this._rawData.Set("cumulative_allocation", value); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// The allocation per individual group /// - public bool? Prorated + public required string GroupAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); + return this._rawData.GetNotNullClass("group_allocation"); } - init + init { this._rawData.Set("group_allocation", value); } + } + + /// + /// The event property used to group usage before applying allocations + /// + public required string GroupingKey + { + get { - if (value == null) - { - return; - } + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } - this._rawData.Set("prorated", value); + /// + /// The amount to charge for each unit outside of the allocation + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); } + init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.MinimumAmount; - _ = this.Prorated; + _ = this.CumulativeAllocation; + _ = this.GroupAllocation; + _ = this.GroupingKey; + _ = this.UnitAmount; } - public MinimumConfig() { } + public CumulativeGroupedAllocationConfig() { } - public MinimumConfig(MinimumConfig minimumConfig) - : base(minimumConfig) { } + public CumulativeGroupedAllocationConfig( + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + ) + : base(cumulativeGroupedAllocationConfig) { } - public MinimumConfig(IReadOnlyDictionary rawData) + public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - MinimumConfig(FrozenDictionary rawData) + CumulativeGroupedAllocationConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static MinimumConfig FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public MinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class MinimumConfigFromRaw : IFromRawJson +class CumulativeGroupedAllocationConfigFromRaw : IFromRawJson { /// - public MinimumConfig FromRawUnchecked(IReadOnlyDictionary rawData) => - MinimumConfig.FromRawUnchecked(rawData); + public CumulativeGroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(PriceMinimumPriceTypeConverter))] -public enum PriceMinimumPriceType +[JsonConverter(typeof(CumulativeGroupedAllocationPriceTypeConverter))] +public enum CumulativeGroupedAllocationPriceType { UsagePrice, FixedPrice, CompositePrice, } -sealed class PriceMinimumPriceTypeConverter : JsonConverter +sealed class CumulativeGroupedAllocationPriceTypeConverter + : JsonConverter { - public override PriceMinimumPriceType Read( + public override CumulativeGroupedAllocationPriceType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -37922,16 +36698,16 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "usage_price" => PriceMinimumPriceType.UsagePrice, - "fixed_price" => PriceMinimumPriceType.FixedPrice, - "composite_price" => PriceMinimumPriceType.CompositePrice, - _ => (PriceMinimumPriceType)(-1), + "usage_price" => CumulativeGroupedAllocationPriceType.UsagePrice, + "fixed_price" => CumulativeGroupedAllocationPriceType.FixedPrice, + "composite_price" => CumulativeGroupedAllocationPriceType.CompositePrice, + _ => (CumulativeGroupedAllocationPriceType)(-1), }; } public override void Write( Utf8JsonWriter writer, - PriceMinimumPriceType value, + CumulativeGroupedAllocationPriceType value, JsonSerializerOptions options ) { @@ -37939,9 +36715,9 @@ JsonSerializerOptions options writer, value switch { - PriceMinimumPriceType.UsagePrice => "usage_price", - PriceMinimumPriceType.FixedPrice => "fixed_price", - PriceMinimumPriceType.CompositePrice => "composite_price", + CumulativeGroupedAllocationPriceType.UsagePrice => "usage_price", + CumulativeGroupedAllocationPriceType.FixedPrice => "fixed_price", + CumulativeGroupedAllocationPriceType.CompositePrice => "composite_price", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Prices/ExternalPriceID/ExternalPriceIDFetchParams.cs b/src/Orb/Models/Prices/ExternalPriceID/ExternalPriceIDFetchParams.cs index db8f76d6..8f318c9c 100644 --- a/src/Orb/Models/Prices/ExternalPriceID/ExternalPriceIDFetchParams.cs +++ b/src/Orb/Models/Prices/ExternalPriceID/ExternalPriceIDFetchParams.cs @@ -11,18 +11,25 @@ namespace Orb.Models.Prices.ExternalPriceID; /// /// This endpoint returns a price given an external price id. See the [price creation /// API](/api-reference/price/create-price) for more information about external price aliases. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ExternalPriceIDFetchParams : ParamsBase +public record class ExternalPriceIDFetchParams : ParamsBase { public string? ExternalPriceID { get; init; } public ExternalPriceIDFetchParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ExternalPriceIDFetchParams(ExternalPriceIDFetchParams externalPriceIDFetchParams) : base(externalPriceIDFetchParams) { this.ExternalPriceID = externalPriceIDFetchParams.ExternalPriceID; } +#pragma warning restore CS8618 public ExternalPriceIDFetchParams( IReadOnlyDictionary rawHeaderData, @@ -57,6 +64,30 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ExternalPriceID"] = this.ExternalPriceID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ExternalPriceIDFetchParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalPriceID?.Equals(other.ExternalPriceID) ?? other.ExternalPriceID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -76,4 +107,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Prices/ExternalPriceID/ExternalPriceIDUpdateParams.cs b/src/Orb/Models/Prices/ExternalPriceID/ExternalPriceIDUpdateParams.cs index dcbbe1f7..e553d535 100644 --- a/src/Orb/Models/Prices/ExternalPriceID/ExternalPriceIDUpdateParams.cs +++ b/src/Orb/Models/Prices/ExternalPriceID/ExternalPriceIDUpdateParams.cs @@ -12,8 +12,12 @@ namespace Orb.Models.Prices.ExternalPriceID; /// /// This endpoint allows you to update the `metadata` property on a price. If you /// pass null for the metadata value, it will clear any existing metadata for that price. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ExternalPriceIDUpdateParams : ParamsBase +public record class ExternalPriceIDUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -48,6 +52,8 @@ public IReadOnlyDictionary RawBodyData public ExternalPriceIDUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ExternalPriceIDUpdateParams(ExternalPriceIDUpdateParams externalPriceIDUpdateParams) : base(externalPriceIDUpdateParams) { @@ -55,6 +61,7 @@ public ExternalPriceIDUpdateParams(ExternalPriceIDUpdateParams externalPriceIDUp this._rawBodyData = new(externalPriceIDUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public ExternalPriceIDUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -95,6 +102,32 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ExternalPriceID"] = this.ExternalPriceID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ExternalPriceIDUpdateParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalPriceID?.Equals(other.ExternalPriceID) ?? other.ExternalPriceID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -123,4 +156,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Prices/PriceCreateParams.cs b/src/Orb/Models/Prices/PriceCreateParams.cs index fcf7c47b..5f126121 100644 --- a/src/Orb/Models/Prices/PriceCreateParams.cs +++ b/src/Orb/Models/Prices/PriceCreateParams.cs @@ -23,8 +23,12 @@ namespace Orb.Models.Prices; /// /// See the [Price resource](/product-catalog/price-configuration) for the /// specification of different price model configurations possible in this endpoint. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class PriceCreateParams : ParamsBase +public record class PriceCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -47,11 +51,14 @@ public required Body Body public PriceCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceCreateParams(PriceCreateParams priceCreateParams) : base(priceCreateParams) { this._rawBodyData = new(priceCreateParams._rawBodyData); } +#pragma warning restore CS8618 public PriceCreateParams( IReadOnlyDictionary rawHeaderData, @@ -92,6 +99,28 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(PriceCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/prices") @@ -117,6 +146,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -173,7 +207,6 @@ public string Currency newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.Currency, newFloatingCumulativeGroupedBulkPrice: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, newFloatingMinimumCompositePrice: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency @@ -214,7 +247,6 @@ public string ItemID newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.ItemID, newFloatingCumulativeGroupedBulkPrice: (x) => x.ItemID, cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, newFloatingMinimumCompositePrice: (x) => x.ItemID, percent: (x) => x.ItemID, eventOutput: (x) => x.ItemID @@ -255,7 +287,6 @@ public string Name newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.Name, newFloatingCumulativeGroupedBulkPrice: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, newFloatingMinimumCompositePrice: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name @@ -296,7 +327,6 @@ public string? BillableMetricID newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.BillableMetricID, newFloatingCumulativeGroupedBulkPrice: (x) => x.BillableMetricID, cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, newFloatingMinimumCompositePrice: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID @@ -337,7 +367,6 @@ public bool? BilledInAdvance newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.BilledInAdvance, newFloatingCumulativeGroupedBulkPrice: (x) => x.BilledInAdvance, cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, newFloatingMinimumCompositePrice: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance @@ -378,7 +407,6 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.BillingCycleConfiguration, newFloatingCumulativeGroupedBulkPrice: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, newFloatingMinimumCompositePrice: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration @@ -419,7 +447,6 @@ public double? ConversionRate newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.ConversionRate, newFloatingCumulativeGroupedBulkPrice: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, newFloatingMinimumCompositePrice: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate @@ -462,7 +489,6 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration x.DimensionalPriceConfiguration, newFloatingCumulativeGroupedBulkPrice: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, newFloatingMinimumCompositePrice: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration @@ -503,7 +529,6 @@ public string? ExternalPriceID newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.ExternalPriceID, newFloatingCumulativeGroupedBulkPrice: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, newFloatingMinimumCompositePrice: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID @@ -544,7 +569,6 @@ public double? FixedPriceQuantity newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.FixedPriceQuantity, newFloatingCumulativeGroupedBulkPrice: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, newFloatingMinimumCompositePrice: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity @@ -585,7 +609,6 @@ public string? InvoiceGroupingKey newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.InvoiceGroupingKey, newFloatingCumulativeGroupedBulkPrice: (x) => x.InvoiceGroupingKey, cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, newFloatingMinimumCompositePrice: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey @@ -627,7 +650,6 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration x.InvoicingCycleConfiguration, newFloatingCumulativeGroupedBulkPrice: (x) => x.InvoicingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, newFloatingMinimumCompositePrice: (x) => x.InvoicingCycleConfiguration, percent: (x) => x.InvoicingCycleConfiguration, eventOutput: (x) => x.InvoicingCycleConfiguration @@ -653,7 +675,7 @@ public Body(NewFloatingBulkPrice value, JsonElement? element = null) this._element = element; } - public Body(global::Orb.Models.Prices.BulkWithFilters value, JsonElement? element = null) + public Body(BulkWithFilters value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -755,10 +777,7 @@ public Body(NewFloatingGroupedWithMeteredMinimumPrice value, JsonElement? elemen this._element = element; } - public Body( - global::Orb.Models.Prices.GroupedWithMinMaxThresholds value, - JsonElement? element = null - ) + public Body(GroupedWithMinMaxThresholds value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -800,16 +819,7 @@ public Body(NewFloatingCumulativeGroupedBulkPrice value, JsonElement? element = this._element = element; } - public Body( - global::Orb.Models.Prices.CumulativeGroupedAllocation value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public Body(global::Orb.Models.Prices.Minimum value, JsonElement? element = null) + public Body(CumulativeGroupedAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -821,13 +831,13 @@ public Body(NewFloatingMinimumCompositePrice value, JsonElement? element = null) this._element = element; } - public Body(global::Orb.Models.Prices.Percent value, JsonElement? element = null) + public Body(Percent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Body(global::Orb.Models.Prices.EventOutput value, JsonElement? element = null) + public Body(EventOutput value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -903,24 +913,22 @@ public bool TryPickNewFloatingBulkPrice([NotNullWhen(true)] out NewFloatingBulkP /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickBulkWithFilters(out var value)) { - /// // `value` is of type `global::Orb.Models.Prices.BulkWithFilters` + /// // `value` is of type `BulkWithFilters` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickBulkWithFilters( - [NotNullWhen(true)] out global::Orb.Models.Prices.BulkWithFilters? value - ) + public bool TryPickBulkWithFilters([NotNullWhen(true)] out BulkWithFilters? value) { - value = this.Value as global::Orb.Models.Prices.BulkWithFilters; + value = this.Value as BulkWithFilters; return value != null; } @@ -1292,24 +1300,24 @@ public bool TryPickNewFloatingGroupedWithMeteredMinimumPrice( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickGroupedWithMinMaxThresholds(out var value)) { - /// // `value` is of type `global::Orb.Models.Prices.GroupedWithMinMaxThresholds` + /// // `value` is of type `GroupedWithMinMaxThresholds` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] out global::Orb.Models.Prices.GroupedWithMinMaxThresholds? value + [NotNullWhen(true)] out GroupedWithMinMaxThresholds? value ) { - value = this.Value as global::Orb.Models.Prices.GroupedWithMinMaxThresholds; + value = this.Value as GroupedWithMinMaxThresholds; return value != null; } @@ -1453,45 +1461,24 @@ public bool TryPickNewFloatingCumulativeGroupedBulkPrice( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `global::Orb.Models.Prices.CumulativeGroupedAllocation` + /// // `value` is of type `CumulativeGroupedAllocation` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] out global::Orb.Models.Prices.CumulativeGroupedAllocation? value + [NotNullWhen(true)] out CumulativeGroupedAllocation? value ) { - value = this.Value as global::Orb.Models.Prices.CumulativeGroupedAllocation; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `global::Orb.Models.Prices.Minimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum([NotNullWhen(true)] out global::Orb.Models.Prices.Minimum? value) - { - value = this.Value as global::Orb.Models.Prices.Minimum; + value = this.Value as CumulativeGroupedAllocation; return value != null; } @@ -1520,45 +1507,43 @@ public bool TryPickNewFloatingMinimumCompositePrice( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickPercent(out var value)) { - /// // `value` is of type `global::Orb.Models.Prices.Percent` + /// // `value` is of type `Percent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickPercent([NotNullWhen(true)] out global::Orb.Models.Prices.Percent? value) + public bool TryPickPercent([NotNullWhen(true)] out Percent? value) { - value = this.Value as global::Orb.Models.Prices.Percent; + value = this.Value as Percent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickEventOutput(out var value)) { - /// // `value` is of type `global::Orb.Models.Prices.EventOutput` + /// // `value` is of type `EventOutput` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickEventOutput( - [NotNullWhen(true)] out global::Orb.Models.Prices.EventOutput? value - ) + public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) { - value = this.Value as global::Orb.Models.Prices.EventOutput; + value = this.Value as EventOutput; return value != null; } @@ -1579,7 +1564,7 @@ public bool TryPickEventOutput( /// (NewFloatingUnitPrice value) => {...}, /// (NewFloatingTieredPrice value) => {...}, /// (NewFloatingBulkPrice value) => {...}, - /// (global::Orb.Models.Prices.BulkWithFilters value) => {...}, + /// (BulkWithFilters value) => {...}, /// (NewFloatingPackagePrice value) => {...}, /// (NewFloatingMatrixPrice value) => {...}, /// (NewFloatingThresholdTotalAmountPrice value) => {...}, @@ -1596,18 +1581,17 @@ public bool TryPickEventOutput( /// (NewFloatingBulkWithProrationPrice value) => {...}, /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Prices.GroupedWithMinMaxThresholds value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, /// (NewFloatingGroupedTieredPackagePrice value) => {...}, /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, - /// (global::Orb.Models.Prices.CumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Prices.Minimum value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Prices.Percent value) => {...}, - /// (global::Orb.Models.Prices.EventOutput value) => {...} + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -1616,7 +1600,7 @@ public void Switch( System::Action newFloatingUnitPrice, System::Action newFloatingTieredPrice, System::Action newFloatingBulkPrice, - System::Action bulkWithFilters, + System::Action bulkWithFilters, System::Action newFloatingPackagePrice, System::Action newFloatingMatrixPrice, System::Action newFloatingThresholdTotalAmountPrice, @@ -1633,18 +1617,17 @@ public void Switch( System::Action newFloatingBulkWithProrationPrice, System::Action newFloatingGroupedWithProratedMinimumPrice, System::Action newFloatingGroupedWithMeteredMinimumPrice, - System::Action groupedWithMinMaxThresholds, + System::Action groupedWithMinMaxThresholds, System::Action newFloatingMatrixWithDisplayNamePrice, System::Action newFloatingGroupedTieredPackagePrice, System::Action newFloatingMaxGroupTieredPackagePrice, System::Action newFloatingScalableMatrixWithUnitPricingPrice, System::Action newFloatingScalableMatrixWithTieredPricingPrice, System::Action newFloatingCumulativeGroupedBulkPrice, - System::Action cumulativeGroupedAllocation, - System::Action minimum, + System::Action cumulativeGroupedAllocation, System::Action newFloatingMinimumCompositePrice, - System::Action percent, - System::Action eventOutput + System::Action percent, + System::Action eventOutput ) { switch (this.Value) @@ -1658,7 +1641,7 @@ public void Switch( case NewFloatingBulkPrice value: newFloatingBulkPrice(value); break; - case global::Orb.Models.Prices.BulkWithFilters value: + case BulkWithFilters value: bulkWithFilters(value); break; case NewFloatingPackagePrice value: @@ -1709,7 +1692,7 @@ public void Switch( case NewFloatingGroupedWithMeteredMinimumPrice value: newFloatingGroupedWithMeteredMinimumPrice(value); break; - case global::Orb.Models.Prices.GroupedWithMinMaxThresholds value: + case GroupedWithMinMaxThresholds value: groupedWithMinMaxThresholds(value); break; case NewFloatingMatrixWithDisplayNamePrice value: @@ -1730,19 +1713,16 @@ public void Switch( case NewFloatingCumulativeGroupedBulkPrice value: newFloatingCumulativeGroupedBulkPrice(value); break; - case global::Orb.Models.Prices.CumulativeGroupedAllocation value: + case CumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case global::Orb.Models.Prices.Minimum value: - minimum(value); - break; case NewFloatingMinimumCompositePrice value: newFloatingMinimumCompositePrice(value); break; - case global::Orb.Models.Prices.Percent value: + case Percent value: percent(value); break; - case global::Orb.Models.Prices.EventOutput value: + case EventOutput value: eventOutput(value); break; default: @@ -1768,7 +1748,7 @@ public void Switch( /// (NewFloatingUnitPrice value) => {...}, /// (NewFloatingTieredPrice value) => {...}, /// (NewFloatingBulkPrice value) => {...}, - /// (global::Orb.Models.Prices.BulkWithFilters value) => {...}, + /// (BulkWithFilters value) => {...}, /// (NewFloatingPackagePrice value) => {...}, /// (NewFloatingMatrixPrice value) => {...}, /// (NewFloatingThresholdTotalAmountPrice value) => {...}, @@ -1785,18 +1765,17 @@ public void Switch( /// (NewFloatingBulkWithProrationPrice value) => {...}, /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Prices.GroupedWithMinMaxThresholds value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, /// (NewFloatingGroupedTieredPackagePrice value) => {...}, /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, - /// (global::Orb.Models.Prices.CumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Prices.Minimum value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Prices.Percent value) => {...}, - /// (global::Orb.Models.Prices.EventOutput value) => {...} + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -1805,7 +1784,7 @@ public T Match( System::Func newFloatingUnitPrice, System::Func newFloatingTieredPrice, System::Func newFloatingBulkPrice, - System::Func bulkWithFilters, + System::Func bulkWithFilters, System::Func newFloatingPackagePrice, System::Func newFloatingMatrixPrice, System::Func newFloatingThresholdTotalAmountPrice, @@ -1834,10 +1813,7 @@ public T Match( NewFloatingGroupedWithMeteredMinimumPrice, T > newFloatingGroupedWithMeteredMinimumPrice, - System::Func< - global::Orb.Models.Prices.GroupedWithMinMaxThresholds, - T - > groupedWithMinMaxThresholds, + System::Func groupedWithMinMaxThresholds, System::Func< NewFloatingMatrixWithDisplayNamePrice, T @@ -1859,14 +1835,10 @@ public T Match( NewFloatingCumulativeGroupedBulkPrice, T > newFloatingCumulativeGroupedBulkPrice, - System::Func< - global::Orb.Models.Prices.CumulativeGroupedAllocation, - T - > cumulativeGroupedAllocation, - System::Func minimum, + System::Func cumulativeGroupedAllocation, System::Func newFloatingMinimumCompositePrice, - System::Func percent, - System::Func eventOutput + System::Func percent, + System::Func eventOutput ) { return this.Value switch @@ -1874,7 +1846,7 @@ public T Match( NewFloatingUnitPrice value => newFloatingUnitPrice(value), NewFloatingTieredPrice value => newFloatingTieredPrice(value), NewFloatingBulkPrice value => newFloatingBulkPrice(value), - global::Orb.Models.Prices.BulkWithFilters value => bulkWithFilters(value), + BulkWithFilters value => bulkWithFilters(value), NewFloatingPackagePrice value => newFloatingPackagePrice(value), NewFloatingMatrixPrice value => newFloatingMatrixPrice(value), NewFloatingThresholdTotalAmountPrice value => newFloatingThresholdTotalAmountPrice( @@ -1900,8 +1872,7 @@ public T Match( newFloatingGroupedWithProratedMinimumPrice(value), NewFloatingGroupedWithMeteredMinimumPrice value => newFloatingGroupedWithMeteredMinimumPrice(value), - global::Orb.Models.Prices.GroupedWithMinMaxThresholds value => - groupedWithMinMaxThresholds(value), + GroupedWithMinMaxThresholds value => groupedWithMinMaxThresholds(value), NewFloatingMatrixWithDisplayNamePrice value => newFloatingMatrixWithDisplayNamePrice( value ), @@ -1918,12 +1889,10 @@ public T Match( NewFloatingCumulativeGroupedBulkPrice value => newFloatingCumulativeGroupedBulkPrice( value ), - global::Orb.Models.Prices.CumulativeGroupedAllocation value => - cumulativeGroupedAllocation(value), - global::Orb.Models.Prices.Minimum value => minimum(value), + CumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), NewFloatingMinimumCompositePrice value => newFloatingMinimumCompositePrice(value), - global::Orb.Models.Prices.Percent value => percent(value), - global::Orb.Models.Prices.EventOutput value => eventOutput(value), + Percent value => percent(value), + EventOutput value => eventOutput(value), _ => throw new OrbInvalidDataException("Data did not match any variant of Body"), }; } @@ -1934,8 +1903,7 @@ public T Match( public static implicit operator Body(NewFloatingBulkPrice value) => new(value); - public static implicit operator Body(global::Orb.Models.Prices.BulkWithFilters value) => - new(value); + public static implicit operator Body(BulkWithFilters value) => new(value); public static implicit operator Body(NewFloatingPackagePrice value) => new(value); @@ -1972,9 +1940,7 @@ public static implicit operator Body(NewFloatingGroupedWithProratedMinimumPrice public static implicit operator Body(NewFloatingGroupedWithMeteredMinimumPrice value) => new(value); - public static implicit operator Body( - global::Orb.Models.Prices.GroupedWithMinMaxThresholds value - ) => new(value); + public static implicit operator Body(GroupedWithMinMaxThresholds value) => new(value); public static implicit operator Body(NewFloatingMatrixWithDisplayNamePrice value) => new(value); @@ -1990,17 +1956,13 @@ public static implicit operator Body(NewFloatingScalableMatrixWithTieredPricingP public static implicit operator Body(NewFloatingCumulativeGroupedBulkPrice value) => new(value); - public static implicit operator Body( - global::Orb.Models.Prices.CumulativeGroupedAllocation value - ) => new(value); - - public static implicit operator Body(global::Orb.Models.Prices.Minimum value) => new(value); + public static implicit operator Body(CumulativeGroupedAllocation value) => new(value); public static implicit operator Body(NewFloatingMinimumCompositePrice value) => new(value); - public static implicit operator Body(global::Orb.Models.Prices.Percent value) => new(value); + public static implicit operator Body(Percent value) => new(value); - public static implicit operator Body(global::Orb.Models.Prices.EventOutput value) => new(value); + public static implicit operator Body(EventOutput value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2059,7 +2021,6 @@ public override void Validate() (newFloatingCumulativeGroupedBulkPrice) => newFloatingCumulativeGroupedBulkPrice.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), (newFloatingMinimumCompositePrice) => newFloatingMinimumCompositePrice.Validate(), (percent) => percent.Validate(), (eventOutput) => eventOutput.Validate() @@ -2171,11 +2132,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2557,11 +2517,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2718,34 +2677,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2786,11 +2721,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -2809,11 +2740,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -2841,25 +2768,18 @@ public override void Write(Utf8JsonWriter writer, Body value, JsonSerializerOpti } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.BulkWithFilters, - global::Orb.Models.Prices.BulkWithFiltersFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class BulkWithFilters : JsonModel { /// /// Configuration for bulk_with_filters pricing /// - public required global::Orb.Models.Prices.BulkWithFiltersConfig BulkWithFiltersConfig + public required BulkWithFiltersConfig BulkWithFiltersConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "bulk_with_filters_config" - ); + return this._rawData.GetNotNullClass("bulk_with_filters_config"); } init { this._rawData.Set("bulk_with_filters_config", value); } } @@ -2867,14 +2787,12 @@ public sealed record class BulkWithFilters : JsonModel /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } @@ -2990,14 +2908,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Prices.ConversionRateConfig? ConversionRateConfig + public ConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); + return this._rawData.GetNullableClass("conversion_rate_config"); } init { this._rawData.Set("conversion_rate_config", value); } } @@ -3128,7 +3044,7 @@ public BulkWithFilters() this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } - public BulkWithFilters(global::Orb.Models.Prices.BulkWithFilters bulkWithFilters) + public BulkWithFilters(BulkWithFilters bulkWithFilters) : base(bulkWithFilters) { } public BulkWithFilters(IReadOnlyDictionary rawData) @@ -3146,49 +3062,39 @@ public BulkWithFilters(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.BulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class BulkWithFiltersFromRaw : IFromRawJson +class BulkWithFiltersFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.BulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.BulkWithFilters.FromRawUnchecked(rawData); + public BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) => + BulkWithFilters.FromRawUnchecked(rawData); } /// /// Configuration for bulk_with_filters pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.BulkWithFiltersConfig, - global::Orb.Models.Prices.BulkWithFiltersConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class BulkWithFiltersConfig : JsonModel { /// /// Property filters to apply (all must match) /// - public required IReadOnlyList Filters + public required IReadOnlyList Filters { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct>( - "filters" - ); + return this._rawData.GetNotNullStruct>("filters"); } init { - this._rawData.Set>( + this._rawData.Set>( "filters", ImmutableArray.ToImmutableArray(value) ); @@ -3198,18 +3104,16 @@ public sealed record class BulkWithFiltersConfig : JsonModel /// /// Bulk tiers for rating based on total usage volume /// - public required IReadOnlyList Tiers + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct>( - "tiers" - ); + return this._rawData.GetNotNullStruct>("tiers"); } init { - this._rawData.Set>( + this._rawData.Set>( "tiers", ImmutableArray.ToImmutableArray(value) ); @@ -3231,9 +3135,7 @@ public override void Validate() public BulkWithFiltersConfig() { } - public BulkWithFiltersConfig( - global::Orb.Models.Prices.BulkWithFiltersConfig bulkWithFiltersConfig - ) + public BulkWithFiltersConfig(BulkWithFiltersConfig bulkWithFiltersConfig) : base(bulkWithFiltersConfig) { } public BulkWithFiltersConfig(IReadOnlyDictionary rawData) @@ -3249,8 +3151,8 @@ public BulkWithFiltersConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.BulkWithFiltersConfig FromRawUnchecked( + /// + public static BulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -3258,23 +3160,18 @@ IReadOnlyDictionary rawData } } -class BulkWithFiltersConfigFromRaw : IFromRawJson +class BulkWithFiltersConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.BulkWithFiltersConfig FromRawUnchecked( + public BulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.BulkWithFiltersConfig.FromRawUnchecked(rawData); + ) => BulkWithFiltersConfig.FromRawUnchecked(rawData); } /// /// Configuration for a single property filter /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.Filter, - global::Orb.Models.Prices.FilterFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Filter : JsonModel { /// @@ -3312,7 +3209,7 @@ public override void Validate() public Filter() { } - public Filter(global::Orb.Models.Prices.Filter filter) + public Filter(Filter filter) : base(filter) { } public Filter(IReadOnlyDictionary rawData) @@ -3328,32 +3225,24 @@ public Filter(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Filter FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class FilterFromRaw : IFromRawJson +class FilterFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.Filter.FromRawUnchecked(rawData); + public Filter FromRawUnchecked(IReadOnlyDictionary rawData) => + Filter.FromRawUnchecked(rawData); } /// /// Configuration for a single bulk pricing tier /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.Tier, - global::Orb.Models.Prices.TierFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Tier : JsonModel { /// @@ -3391,7 +3280,7 @@ public override void Validate() public Tier() { } - public Tier(global::Orb.Models.Prices.Tier tier) + public Tier(Tier tier) : base(tier) { } public Tier(IReadOnlyDictionary rawData) @@ -3407,10 +3296,8 @@ public Tier(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Tier FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } @@ -3423,18 +3310,17 @@ public Tier(string unitAmount) } } -class TierFromRaw : IFromRawJson +class TierFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.Tier.FromRawUnchecked(rawData); + public Tier FromRawUnchecked(IReadOnlyDictionary rawData) => + Tier.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Prices.CadenceConverter))] +[JsonConverter(typeof(CadenceConverter))] public enum Cadence { Annual, @@ -3445,9 +3331,9 @@ public enum Cadence Custom, } -sealed class CadenceConverter : JsonConverter +sealed class CadenceConverter : JsonConverter { - public override global::Orb.Models.Prices.Cadence Read( + public override Cadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -3455,32 +3341,28 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Prices.Cadence.Annual, - "semi_annual" => global::Orb.Models.Prices.Cadence.SemiAnnual, - "monthly" => global::Orb.Models.Prices.Cadence.Monthly, - "quarterly" => global::Orb.Models.Prices.Cadence.Quarterly, - "one_time" => global::Orb.Models.Prices.Cadence.OneTime, - "custom" => global::Orb.Models.Prices.Cadence.Custom, - _ => (global::Orb.Models.Prices.Cadence)(-1), + "annual" => Cadence.Annual, + "semi_annual" => Cadence.SemiAnnual, + "monthly" => Cadence.Monthly, + "quarterly" => Cadence.Quarterly, + "one_time" => Cadence.OneTime, + "custom" => Cadence.Custom, + _ => (Cadence)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Prices.Cadence value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Cadence value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Prices.Cadence.Annual => "annual", - global::Orb.Models.Prices.Cadence.SemiAnnual => "semi_annual", - global::Orb.Models.Prices.Cadence.Monthly => "monthly", - global::Orb.Models.Prices.Cadence.Quarterly => "quarterly", - global::Orb.Models.Prices.Cadence.OneTime => "one_time", - global::Orb.Models.Prices.Cadence.Custom => "custom", + Cadence.Annual => "annual", + Cadence.SemiAnnual => "semi_annual", + Cadence.Monthly => "monthly", + Cadence.Quarterly => "quarterly", + Cadence.OneTime => "one_time", + Cadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -3490,7 +3372,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.Prices.ConversionRateConfigConverter))] +[JsonConverter(typeof(ConversionRateConfigConverter))] public record class ConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -3643,13 +3525,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Prices.ConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); + public static implicit operator ConversionRateConfig(SharedUnitConversionRateConfig value) => + new(value); - public static implicit operator global::Orb.Models.Prices.ConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); + public static implicit operator ConversionRateConfig(SharedTieredConversionRateConfig value) => + new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -3672,7 +3552,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Prices.ConversionRateConfig? other) + public virtual bool Equals(ConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -3686,10 +3566,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class ConversionRateConfigConverter - : JsonConverter +sealed class ConversionRateConfigConverter : JsonConverter { - public override global::Orb.Models.Prices.ConversionRateConfig? Read( + public override ConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -3754,14 +3633,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Prices.ConversionRateConfig(element); + return new ConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Prices.ConversionRateConfig value, + ConversionRateConfig value, JsonSerializerOptions options ) { @@ -3770,26 +3649,20 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.GroupedWithMinMaxThresholds, - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class GroupedWithMinMaxThresholds : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -3811,12 +3684,12 @@ public required string Currency /// /// Configuration for grouped_with_min_max_thresholds pricing /// - public required global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + public required GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "grouped_with_min_max_thresholds_config" ); } @@ -3921,12 +3794,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + public GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -4059,9 +3932,7 @@ public GroupedWithMinMaxThresholds() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } - public GroupedWithMinMaxThresholds( - global::Orb.Models.Prices.GroupedWithMinMaxThresholds groupedWithMinMaxThresholds - ) + public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) : base(groupedWithMinMaxThresholds) { } public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) @@ -4079,8 +3950,8 @@ public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawD } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.GroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4088,19 +3959,18 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class GroupedWithMinMaxThresholdsFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.GroupedWithMinMaxThresholds FromRawUnchecked( + public GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + ) => GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadenceConverter))] +[JsonConverter(typeof(GroupedWithMinMaxThresholdsCadenceConverter))] public enum GroupedWithMinMaxThresholdsCadence { Annual, @@ -4112,9 +3982,9 @@ public enum GroupedWithMinMaxThresholdsCadence } sealed class GroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence Read( + public override GroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4122,23 +3992,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence.Annual, - "semi_annual" => global::Orb - .Models - .Prices - .GroupedWithMinMaxThresholdsCadence - .SemiAnnual, - "monthly" => global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence.Monthly, - "quarterly" => global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence.Quarterly, - "one_time" => global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence.OneTime, - "custom" => global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence.Custom, - _ => (global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence)(-1), + "annual" => GroupedWithMinMaxThresholdsCadence.Annual, + "semi_annual" => GroupedWithMinMaxThresholdsCadence.SemiAnnual, + "monthly" => GroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => GroupedWithMinMaxThresholdsCadence.Quarterly, + "one_time" => GroupedWithMinMaxThresholdsCadence.OneTime, + "custom" => GroupedWithMinMaxThresholdsCadence.Custom, + _ => (GroupedWithMinMaxThresholdsCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence value, + GroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -4146,14 +4012,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence.Annual => "annual", - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence.SemiAnnual => - "semi_annual", - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence.Monthly => "monthly", - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence.Quarterly => - "quarterly", - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence.OneTime => "one_time", - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence.Custom => "custom", + GroupedWithMinMaxThresholdsCadence.Annual => "annual", + GroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", + GroupedWithMinMaxThresholdsCadence.Monthly => "monthly", + GroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", + GroupedWithMinMaxThresholdsCadence.OneTime => "one_time", + GroupedWithMinMaxThresholdsCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -4168,8 +4032,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfig, - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfigFromRaw + GroupedWithMinMaxThresholdsConfig, + GroupedWithMinMaxThresholdsConfigFromRaw >) )] public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel @@ -4238,7 +4102,7 @@ public override void Validate() public GroupedWithMinMaxThresholdsConfig() { } public GroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig + GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) : base(groupedWithMinMaxThresholdsConfig) { } @@ -4255,8 +4119,8 @@ public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary - public static global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4264,18 +4128,15 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class GroupedWithMinMaxThresholdsConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); + ) => GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConversionRateConfigConverter) -)] +[JsonConverter(typeof(GroupedWithMinMaxThresholdsConversionRateConfigConverter))] public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -4434,11 +4295,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -4463,9 +4324,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConversionRateConfig? other - ) + public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -4480,9 +4339,9 @@ public override string ToString() => } sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override GroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4547,16 +4406,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConversionRateConfig( - element - ); + return new GroupedWithMinMaxThresholdsConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConversionRateConfig value, + GroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -4565,26 +4422,20 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.CumulativeGroupedAllocation, - global::Orb.Models.Prices.CumulativeGroupedAllocationFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class CumulativeGroupedAllocation : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Prices.CumulativeGroupedAllocationCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -4593,12 +4444,12 @@ public required ApiEnum< /// /// Configuration for cumulative_grouped_allocation pricing /// - public required global::Orb.Models.Prices.CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "cumulative_grouped_allocation_config" ); } @@ -4716,12 +4567,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Prices.CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + public CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -4854,9 +4705,7 @@ public CumulativeGroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public CumulativeGroupedAllocation( - global::Orb.Models.Prices.CumulativeGroupedAllocation cumulativeGroupedAllocation - ) + public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) : base(cumulativeGroupedAllocation) { } public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) @@ -4874,8 +4723,8 @@ public CumulativeGroupedAllocation(IReadOnlyDictionary rawD } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.CumulativeGroupedAllocation FromRawUnchecked( + /// + public static CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4883,19 +4732,18 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationFromRaw - : IFromRawJson +class CumulativeGroupedAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.CumulativeGroupedAllocation FromRawUnchecked( + public CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.CumulativeGroupedAllocation.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Prices.CumulativeGroupedAllocationCadenceConverter))] +[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] public enum CumulativeGroupedAllocationCadence { Annual, @@ -4907,9 +4755,9 @@ public enum CumulativeGroupedAllocationCadence } sealed class CumulativeGroupedAllocationCadenceConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Prices.CumulativeGroupedAllocationCadence Read( + public override CumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4917,23 +4765,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Prices.CumulativeGroupedAllocationCadence.Annual, - "semi_annual" => global::Orb - .Models - .Prices - .CumulativeGroupedAllocationCadence - .SemiAnnual, - "monthly" => global::Orb.Models.Prices.CumulativeGroupedAllocationCadence.Monthly, - "quarterly" => global::Orb.Models.Prices.CumulativeGroupedAllocationCadence.Quarterly, - "one_time" => global::Orb.Models.Prices.CumulativeGroupedAllocationCadence.OneTime, - "custom" => global::Orb.Models.Prices.CumulativeGroupedAllocationCadence.Custom, - _ => (global::Orb.Models.Prices.CumulativeGroupedAllocationCadence)(-1), + "annual" => CumulativeGroupedAllocationCadence.Annual, + "semi_annual" => CumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => CumulativeGroupedAllocationCadence.Monthly, + "quarterly" => CumulativeGroupedAllocationCadence.Quarterly, + "one_time" => CumulativeGroupedAllocationCadence.OneTime, + "custom" => CumulativeGroupedAllocationCadence.Custom, + _ => (CumulativeGroupedAllocationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Prices.CumulativeGroupedAllocationCadence value, + CumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -4941,14 +4785,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Prices.CumulativeGroupedAllocationCadence.Annual => "annual", - global::Orb.Models.Prices.CumulativeGroupedAllocationCadence.SemiAnnual => - "semi_annual", - global::Orb.Models.Prices.CumulativeGroupedAllocationCadence.Monthly => "monthly", - global::Orb.Models.Prices.CumulativeGroupedAllocationCadence.Quarterly => - "quarterly", - global::Orb.Models.Prices.CumulativeGroupedAllocationCadence.OneTime => "one_time", - global::Orb.Models.Prices.CumulativeGroupedAllocationCadence.Custom => "custom", + CumulativeGroupedAllocationCadence.Annual => "annual", + CumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", + CumulativeGroupedAllocationCadence.Monthly => "monthly", + CumulativeGroupedAllocationCadence.Quarterly => "quarterly", + CumulativeGroupedAllocationCadence.OneTime => "one_time", + CumulativeGroupedAllocationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -4963,8 +4805,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Prices.CumulativeGroupedAllocationConfig, - global::Orb.Models.Prices.CumulativeGroupedAllocationConfigFromRaw + CumulativeGroupedAllocationConfig, + CumulativeGroupedAllocationConfigFromRaw >) )] public sealed record class CumulativeGroupedAllocationConfig : JsonModel @@ -5033,7 +4875,7 @@ public override void Validate() public CumulativeGroupedAllocationConfig() { } public CumulativeGroupedAllocationConfig( - global::Orb.Models.Prices.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig ) : base(cumulativeGroupedAllocationConfig) { } @@ -5050,8 +4892,8 @@ public CumulativeGroupedAllocationConfig(IReadOnlyDictionary - public static global::Orb.Models.Prices.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5059,18 +4901,15 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class CumulativeGroupedAllocationConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.CumulativeGroupedAllocationConfig FromRawUnchecked( + public CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Prices.CumulativeGroupedAllocationConversionRateConfigConverter) -)] +[JsonConverter(typeof(CumulativeGroupedAllocationConversionRateConfigConverter))] public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5229,11 +5068,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Prices.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Prices.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -5258,9 +5097,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Prices.CumulativeGroupedAllocationConversionRateConfig? other - ) + public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -5275,9 +5112,9 @@ public override string ToString() => } sealed class CumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Prices.CumulativeGroupedAllocationConversionRateConfig? Read( + public override CumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5342,16 +5179,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Prices.CumulativeGroupedAllocationConversionRateConfig( - element - ); + return new CumulativeGroupedAllocationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Prices.CumulativeGroupedAllocationConversionRateConfig value, + CumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -5359,23 +5194,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.Minimum, - global::Orb.Models.Prices.MinimumFromRaw - >) -)] -public sealed record class Minimum : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Percent : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>("cadence"); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } @@ -5407,44 +5237,42 @@ public required string ItemID } /// - /// Configuration for minimum pricing + /// The pricing model type /// - public required global::Orb.Models.Prices.MinimumConfig MinimumConfig + public JsonElement ModelType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" - ); + return this._rawData.GetNotNullStruct("model_type"); } - init { this._rawData.Set("minimum_config", value); } + init { this._rawData.Set("model_type", value); } } /// - /// The pricing model type + /// The name of the price. /// - public JsonElement ModelType + public required string Name { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); + return this._rawData.GetNotNullClass("name"); } - init { this._rawData.Set("model_type", value); } + init { this._rawData.Set("name", value); } } /// - /// The name of the price. + /// Configuration for percent pricing /// - public required string Name + public required PercentConfig PercentConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); + return this._rawData.GetNotNullClass("percent_config"); } - init { this._rawData.Set("name", value); } + init { this._rawData.Set("percent_config", value); } } /// @@ -5506,12 +5334,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public MinimumConversionRateConfig? ConversionRateConfig + public PercentConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5615,12 +5443,12 @@ public override void Validate() this.Cadence.Validate(); _ = this.Currency; _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("percent"))) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; + this.PercentConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -5634,51 +5462,48 @@ public override void Validate() _ = this.Metadata; } - public Minimum() + public Percent() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public Minimum(global::Orb.Models.Prices.Minimum minimum) - : base(minimum) { } + public Percent(Percent percent) + : base(percent) { } - public Minimum(IReadOnlyDictionary rawData) + public Percent(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Minimum(FrozenDictionary rawData) + Percent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Percent FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class MinimumFromRaw : IFromRawJson +class PercentFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.Minimum.FromRawUnchecked(rawData); + public Percent FromRawUnchecked(IReadOnlyDictionary rawData) => + Percent.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(MinimumCadenceConverter))] -public enum MinimumCadence +[JsonConverter(typeof(PercentCadenceConverter))] +public enum PercentCadence { Annual, SemiAnnual, @@ -5688,9 +5513,9 @@ public enum MinimumCadence Custom, } -sealed class MinimumCadenceConverter : JsonConverter +sealed class PercentCadenceConverter : JsonConverter { - public override MinimumCadence Read( + public override PercentCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5698,19 +5523,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => MinimumCadence.Annual, - "semi_annual" => MinimumCadence.SemiAnnual, - "monthly" => MinimumCadence.Monthly, - "quarterly" => MinimumCadence.Quarterly, - "one_time" => MinimumCadence.OneTime, - "custom" => MinimumCadence.Custom, - _ => (MinimumCadence)(-1), + "annual" => PercentCadence.Annual, + "semi_annual" => PercentCadence.SemiAnnual, + "monthly" => PercentCadence.Monthly, + "quarterly" => PercentCadence.Quarterly, + "one_time" => PercentCadence.OneTime, + "custom" => PercentCadence.Custom, + _ => (PercentCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - MinimumCadence value, + PercentCadence value, JsonSerializerOptions options ) { @@ -5718,12 +5543,12 @@ JsonSerializerOptions options writer, value switch { - MinimumCadence.Annual => "annual", - MinimumCadence.SemiAnnual => "semi_annual", - MinimumCadence.Monthly => "monthly", - MinimumCadence.Quarterly => "quarterly", - MinimumCadence.OneTime => "one_time", - MinimumCadence.Custom => "custom", + PercentCadence.Annual => "annual", + PercentCadence.SemiAnnual => "semi_annual", + PercentCadence.Monthly => "monthly", + PercentCadence.Quarterly => "quarterly", + PercentCadence.OneTime => "one_time", + PercentCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -5734,101 +5559,71 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for percent pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.MinimumConfig, - global::Orb.Models.Prices.MinimumConfigFromRaw - >) -)] -public sealed record class MinimumConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PercentConfig : JsonModel { /// - /// The minimum amount to apply - /// - public required string MinimumAmount - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); - } - init { this._rawData.Set("minimum_amount", value); } - } - - /// - /// If true, subtotals from this price are prorated based on the service period + /// What percent of the component subtotals to charge /// - public bool? Prorated + public required double Percent { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); - } - init - { - if (value == null) - { - return; - } - - this._rawData.Set("prorated", value); + return this._rawData.GetNotNullStruct("percent"); } + init { this._rawData.Set("percent", value); } } /// public override void Validate() { - _ = this.MinimumAmount; - _ = this.Prorated; + _ = this.Percent; } - public MinimumConfig() { } + public PercentConfig() { } - public MinimumConfig(global::Orb.Models.Prices.MinimumConfig minimumConfig) - : base(minimumConfig) { } + public PercentConfig(PercentConfig percentConfig) + : base(percentConfig) { } - public MinimumConfig(IReadOnlyDictionary rawData) + public PercentConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - MinimumConfig(FrozenDictionary rawData) + PercentConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } [SetsRequiredMembers] - public MinimumConfig(string minimumAmount) + public PercentConfig(double percent) : this() { - this.MinimumAmount = minimumAmount; + this.Percent = percent; } } -class MinimumConfigFromRaw : IFromRawJson +class PercentConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.MinimumConfig.FromRawUnchecked(rawData); + public PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + PercentConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(MinimumConversionRateConfigConverter))] -public record class MinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(PercentConversionRateConfigConverter))] +public record class PercentConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5845,7 +5640,7 @@ public JsonElement Json } } - public MinimumConversionRateConfig( + public PercentConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5854,7 +5649,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig( + public PercentConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5863,7 +5658,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig(JsonElement element) + public PercentConversionRateConfig(JsonElement element) { this._element = element; } @@ -5945,7 +5740,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of PercentConversionRateConfig" ); } } @@ -5981,16 +5776,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of PercentConversionRateConfig" ), }; } - public static implicit operator MinimumConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator MinimumConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6009,13 +5804,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of PercentConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(MinimumConversionRateConfig? other) + public virtual bool Equals(PercentConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -6029,9 +5824,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class MinimumConversionRateConfigConverter : JsonConverter +sealed class PercentConversionRateConfigConverter : JsonConverter { - public override MinimumConversionRateConfig? Read( + public override PercentConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6096,14 +5891,14 @@ JsonSerializerOptions options } default: { - return new MinimumConversionRateConfig(element); + return new PercentConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - MinimumConversionRateConfig value, + PercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -6111,25 +5906,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.Percent, - global::Orb.Models.Prices.PercentFromRaw - >) -)] -public sealed record class Percent : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class EventOutput : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } @@ -6148,751 +5936,16 @@ public required string Currency } /// - /// The id of the item the price will be associated with. + /// Configuration for event_output pricing /// - public required string ItemID + public required EventOutputConfig EventOutputConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass("event_output_config"); } - init { this._rawData.Set("item_id", value); } - } - - /// - /// The pricing model type - /// - public JsonElement ModelType - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); - } - init { this._rawData.Set("model_type", value); } - } - - /// - /// The name of the price. - /// - public required string Name - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } - } - - /// - /// Configuration for percent pricing - /// - public required global::Orb.Models.Prices.PercentConfig PercentConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "percent_config" - ); - } - init { this._rawData.Set("percent_config", value); } - } - - /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. - /// - public string? BillableMetricID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); - } - init { this._rawData.Set("billable_metric_id", value); } - } - - /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. - /// - public bool? BilledInAdvance - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); - } - init { this._rawData.Set("billed_in_advance", value); } - } - - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } - } - - /// - /// The per unit conversion rate of the price currency to the invoicing currency. - /// - public double? ConversionRate - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); - } - init { this._rawData.Set("conversion_rate", value); } - } - - /// - /// The configuration for the rate of the price currency to the invoicing currency. - /// - public global::Orb.Models.Prices.PercentConversionRateConfig? ConversionRateConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", value); } - } - - /// - /// For dimensional price: specifies a price group and dimension values - /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } - } - - /// - /// An alias for the price. - /// - public string? ExternalPriceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } - } - - /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. - /// - public double? FixedPriceQuantity - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } - } - - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", value); } - } - - /// - /// Within each billing cycle, specifies the cadence at which invoices are produced. - /// If unspecified, a single invoice is produced per billing cycle. - /// - public NewBillingCycleConfiguration? InvoicingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); - } - init { this._rawData.Set("invoicing_cycle_configuration", value); } - } - - /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared - /// by setting `metadata` to `null`. - /// - public IReadOnlyDictionary? Metadata - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) - ); - } - } - - /// - public override void Validate() - { - this.Cadence.Validate(); - _ = this.Currency; - _ = this.ItemID; - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("percent"))) - { - throw new OrbInvalidDataException("Invalid value given for constant"); - } - _ = this.Name; - this.PercentConfig.Validate(); - _ = this.BillableMetricID; - _ = this.BilledInAdvance; - this.BillingCycleConfiguration?.Validate(); - _ = this.ConversionRate; - this.ConversionRateConfig?.Validate(); - this.DimensionalPriceConfiguration?.Validate(); - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.InvoiceGroupingKey; - this.InvoicingCycleConfiguration?.Validate(); - _ = this.Metadata; - } - - public Percent() - { - this.ModelType = JsonSerializer.SerializeToElement("percent"); - } - - public Percent(global::Orb.Models.Prices.Percent percent) - : base(percent) { } - - public Percent(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("percent"); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Percent(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static global::Orb.Models.Prices.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class PercentFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Prices.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.Percent.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(global::Orb.Models.Prices.PercentCadenceConverter))] -public enum PercentCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class PercentCadenceConverter : JsonConverter -{ - public override global::Orb.Models.Prices.PercentCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => global::Orb.Models.Prices.PercentCadence.Annual, - "semi_annual" => global::Orb.Models.Prices.PercentCadence.SemiAnnual, - "monthly" => global::Orb.Models.Prices.PercentCadence.Monthly, - "quarterly" => global::Orb.Models.Prices.PercentCadence.Quarterly, - "one_time" => global::Orb.Models.Prices.PercentCadence.OneTime, - "custom" => global::Orb.Models.Prices.PercentCadence.Custom, - _ => (global::Orb.Models.Prices.PercentCadence)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Prices.PercentCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - global::Orb.Models.Prices.PercentCadence.Annual => "annual", - global::Orb.Models.Prices.PercentCadence.SemiAnnual => "semi_annual", - global::Orb.Models.Prices.PercentCadence.Monthly => "monthly", - global::Orb.Models.Prices.PercentCadence.Quarterly => "quarterly", - global::Orb.Models.Prices.PercentCadence.OneTime => "one_time", - global::Orb.Models.Prices.PercentCadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} - -/// -/// Configuration for percent pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.PercentConfig, - global::Orb.Models.Prices.PercentConfigFromRaw - >) -)] -public sealed record class PercentConfig : JsonModel -{ - /// - /// What percent of the component subtotals to charge - /// - public required double Percent - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("percent"); - } - init { this._rawData.Set("percent", value); } - } - - /// - public override void Validate() - { - _ = this.Percent; - } - - public PercentConfig() { } - - public PercentConfig(global::Orb.Models.Prices.PercentConfig percentConfig) - : base(percentConfig) { } - - public PercentConfig(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - PercentConfig(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static global::Orb.Models.Prices.PercentConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public PercentConfig(double percent) - : this() - { - this.Percent = percent; - } -} - -class PercentConfigFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Prices.PercentConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.PercentConfig.FromRawUnchecked(rawData); -} - -[JsonConverter(typeof(global::Orb.Models.Prices.PercentConversionRateConfigConverter))] -public record class PercentConversionRateConfig : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - - public JsonElement Json - { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } - } - - public PercentConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public PercentConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public PercentConversionRateConfig(JsonElement element) - { - this._element = element; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) - { - value = this.Value as SharedUnitConversionRateConfig; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) - { - value = this.Value as SharedTieredConversionRateConfig; - return value != null; - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action unit, - System::Action tiered - ) - { - switch (this.Value) - { - case SharedUnitConversionRateConfig value: - unit(value); - break; - case SharedTieredConversionRateConfig value: - tiered(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" - ); - } - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func unit, - System::Func tiered - ) - { - return this.Value switch - { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" - ), - }; - } - - public static implicit operator global::Orb.Models.Prices.PercentConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); - - public static implicit operator global::Orb.Models.Prices.PercentConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); - - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() - { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" - ); - } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); - } - - public virtual bool Equals(global::Orb.Models.Prices.PercentConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } - - public override int GetHashCode() - { - return 0; - } - - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class PercentConversionRateConfigConverter - : JsonConverter -{ - public override global::Orb.Models.Prices.PercentConversionRateConfig? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; - try - { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); - } - catch - { - conversionRateType = null; - } - - switch (conversionRateType) - { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new global::Orb.Models.Prices.PercentConversionRateConfig(element); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Prices.PercentConversionRateConfig value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } -} - -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.EventOutput, - global::Orb.Models.Prices.EventOutputFromRaw - >) -)] -public sealed record class EventOutput : JsonModel -{ - /// - /// The cadence to bill for this price on. - /// - public required ApiEnum Cadence - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); - } - init { this._rawData.Set("cadence", value); } - } - - /// - /// An ISO 4217 currency string for which this price is billed in. - /// - public required string Currency - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("currency"); - } - init { this._rawData.Set("currency", value); } - } - - /// - /// Configuration for event_output pricing - /// - public required global::Orb.Models.Prices.EventOutputConfig EventOutputConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "event_output_config" - ); - } - init { this._rawData.Set("event_output_config", value); } + init { this._rawData.Set("event_output_config", value); } } /// @@ -6993,12 +6046,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Prices.EventOutputConversionRateConfig? ConversionRateConfig + public EventOutputConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -7131,7 +6184,7 @@ public EventOutput() this.ModelType = JsonSerializer.SerializeToElement("event_output"); } - public EventOutput(global::Orb.Models.Prices.EventOutput eventOutput) + public EventOutput(EventOutput eventOutput) : base(eventOutput) { } public EventOutput(IReadOnlyDictionary rawData) @@ -7149,27 +6202,24 @@ public EventOutput(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.EventOutput FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class EventOutputFromRaw : IFromRawJson +class EventOutputFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.EventOutput FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.EventOutput.FromRawUnchecked(rawData); + public EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutput.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Prices.EventOutputCadenceConverter))] +[JsonConverter(typeof(EventOutputCadenceConverter))] public enum EventOutputCadence { Annual, @@ -7180,10 +6230,9 @@ public enum EventOutputCadence Custom, } -sealed class EventOutputCadenceConverter - : JsonConverter +sealed class EventOutputCadenceConverter : JsonConverter { - public override global::Orb.Models.Prices.EventOutputCadence Read( + public override EventOutputCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7191,19 +6240,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Prices.EventOutputCadence.Annual, - "semi_annual" => global::Orb.Models.Prices.EventOutputCadence.SemiAnnual, - "monthly" => global::Orb.Models.Prices.EventOutputCadence.Monthly, - "quarterly" => global::Orb.Models.Prices.EventOutputCadence.Quarterly, - "one_time" => global::Orb.Models.Prices.EventOutputCadence.OneTime, - "custom" => global::Orb.Models.Prices.EventOutputCadence.Custom, - _ => (global::Orb.Models.Prices.EventOutputCadence)(-1), + "annual" => EventOutputCadence.Annual, + "semi_annual" => EventOutputCadence.SemiAnnual, + "monthly" => EventOutputCadence.Monthly, + "quarterly" => EventOutputCadence.Quarterly, + "one_time" => EventOutputCadence.OneTime, + "custom" => EventOutputCadence.Custom, + _ => (EventOutputCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Prices.EventOutputCadence value, + EventOutputCadence value, JsonSerializerOptions options ) { @@ -7211,12 +6260,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Prices.EventOutputCadence.Annual => "annual", - global::Orb.Models.Prices.EventOutputCadence.SemiAnnual => "semi_annual", - global::Orb.Models.Prices.EventOutputCadence.Monthly => "monthly", - global::Orb.Models.Prices.EventOutputCadence.Quarterly => "quarterly", - global::Orb.Models.Prices.EventOutputCadence.OneTime => "one_time", - global::Orb.Models.Prices.EventOutputCadence.Custom => "custom", + EventOutputCadence.Annual => "annual", + EventOutputCadence.SemiAnnual => "semi_annual", + EventOutputCadence.Monthly => "monthly", + EventOutputCadence.Quarterly => "quarterly", + EventOutputCadence.OneTime => "one_time", + EventOutputCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -7229,12 +6278,7 @@ JsonSerializerOptions options /// /// Configuration for event_output pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.EventOutputConfig, - global::Orb.Models.Prices.EventOutputConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class EventOutputConfig : JsonModel { /// @@ -7289,7 +6333,7 @@ public override void Validate() public EventOutputConfig() { } - public EventOutputConfig(global::Orb.Models.Prices.EventOutputConfig eventOutputConfig) + public EventOutputConfig(EventOutputConfig eventOutputConfig) : base(eventOutputConfig) { } public EventOutputConfig(IReadOnlyDictionary rawData) @@ -7305,8 +6349,8 @@ public EventOutputConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.EventOutputConfig FromRawUnchecked( + /// + public static EventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -7321,15 +6365,14 @@ public EventOutputConfig(string unitRatingKey) } } -class EventOutputConfigFromRaw : IFromRawJson +class EventOutputConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.EventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.EventOutputConfig.FromRawUnchecked(rawData); + public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutputConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Prices.EventOutputConversionRateConfigConverter))] +[JsonConverter(typeof(EventOutputConversionRateConfigConverter))] public record class EventOutputConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -7488,11 +6531,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Prices.EventOutputConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Prices.EventOutputConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7517,7 +6560,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Prices.EventOutputConversionRateConfig? other) + public virtual bool Equals(EventOutputConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -7532,9 +6575,9 @@ public override string ToString() => } sealed class EventOutputConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Prices.EventOutputConversionRateConfig? Read( + public override EventOutputConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7599,14 +6642,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Prices.EventOutputConversionRateConfig(element); + return new EventOutputConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Prices.EventOutputConversionRateConfig value, + EventOutputConversionRateConfig value, JsonSerializerOptions options ) { diff --git a/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs b/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs index 171d505f..ab6cca77 100644 --- a/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs +++ b/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs @@ -39,8 +39,12 @@ namespace Orb.Models.Prices; /// /// Note that this is a POST endpoint rather than a GET endpoint because it /// employs a JSON body rather than query parameters. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class PriceEvaluateMultipleParams : ParamsBase +public record class PriceEvaluateMultipleParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -128,11 +132,14 @@ public IReadOnlyList? PriceEvaluations public PriceEvaluateMultipleParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluateMultipleParams(PriceEvaluateMultipleParams priceEvaluateMultipleParams) : base(priceEvaluateMultipleParams) { this._rawBodyData = new(priceEvaluateMultipleParams._rawBodyData); } +#pragma warning restore CS8618 public PriceEvaluateMultipleParams( IReadOnlyDictionary rawHeaderData, @@ -173,6 +180,28 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(PriceEvaluateMultipleParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/prices/evaluate") @@ -198,6 +227,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(JsonModelConverter))] @@ -258,12 +292,12 @@ public IReadOnlyList? GroupingKeys /// /// New floating price request body params. /// - public global::Orb.Models.Prices.Price? Price + public Price? Price { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("price"); + return this._rawData.GetNullableClass("price"); } init { this._rawData.Set("price", value); } } @@ -326,7 +360,7 @@ public PriceEvaluation FromRawUnchecked(IReadOnlyDictionary /// /// New floating price request body params. /// -[JsonConverter(typeof(global::Orb.Models.Prices.PriceConverter))] +[JsonConverter(typeof(PriceConverter))] public record class Price : ModelBase { public object? Value { get; } = null; @@ -377,7 +411,6 @@ public string Currency newFloatingScalableMatrixWithTieredPricing: (x) => x.Currency, newFloatingCumulativeGroupedBulk: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, newFloatingMinimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency @@ -418,7 +451,6 @@ public string ItemID newFloatingScalableMatrixWithTieredPricing: (x) => x.ItemID, newFloatingCumulativeGroupedBulk: (x) => x.ItemID, cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, newFloatingMinimumComposite: (x) => x.ItemID, percent: (x) => x.ItemID, eventOutput: (x) => x.ItemID @@ -459,7 +491,6 @@ public string Name newFloatingScalableMatrixWithTieredPricing: (x) => x.Name, newFloatingCumulativeGroupedBulk: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, newFloatingMinimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name @@ -500,7 +531,6 @@ public string? BillableMetricID newFloatingScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, newFloatingCumulativeGroupedBulk: (x) => x.BillableMetricID, cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, newFloatingMinimumComposite: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID @@ -541,7 +571,6 @@ public bool? BilledInAdvance newFloatingScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, newFloatingCumulativeGroupedBulk: (x) => x.BilledInAdvance, cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, newFloatingMinimumComposite: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance @@ -582,7 +611,6 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newFloatingScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, newFloatingCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, newFloatingMinimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration @@ -623,7 +651,6 @@ public double? ConversionRate newFloatingScalableMatrixWithTieredPricing: (x) => x.ConversionRate, newFloatingCumulativeGroupedBulk: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, newFloatingMinimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate @@ -664,7 +691,6 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration newFloatingScalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, newFloatingCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, newFloatingMinimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration @@ -705,7 +731,6 @@ public string? ExternalPriceID newFloatingScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, newFloatingCumulativeGroupedBulk: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, newFloatingMinimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID @@ -746,7 +771,6 @@ public double? FixedPriceQuantity newFloatingScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, newFloatingCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, newFloatingMinimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity @@ -787,7 +811,6 @@ public string? InvoiceGroupingKey newFloatingScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, newFloatingCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, newFloatingMinimumComposite: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey @@ -828,7 +851,6 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration newFloatingScalableMatrixWithTieredPricing: (x) => x.InvoicingCycleConfiguration, newFloatingCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, newFloatingMinimumComposite: (x) => x.InvoicingCycleConfiguration, percent: (x) => x.InvoicingCycleConfiguration, eventOutput: (x) => x.InvoicingCycleConfiguration @@ -1004,12 +1026,6 @@ public Price(PriceCumulativeGroupedAllocation value, JsonElement? element = null this._element = element; } - public Price(global::Orb.Models.Prices.PriceMinimum value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - public Price(NewFloatingMinimumCompositePrice value, JsonElement? element = null) { this.Value = value; @@ -1665,29 +1681,6 @@ public bool TryPickCumulativeGroupedAllocation( return value != null; } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `global::Orb.Models.Prices.PriceMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum( - [NotNullWhen(true)] out global::Orb.Models.Prices.PriceMinimum? value - ) - { - value = this.Value as global::Orb.Models.Prices.PriceMinimum; - return value != null; - } - /// /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . @@ -1795,7 +1788,6 @@ public bool TryPickEventOutput([NotNullWhen(true)] out PriceEventOutput? value) /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, /// (PriceCumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Prices.PriceMinimum value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, /// (PricePercent value) => {...}, /// (PriceEventOutput value) => {...} @@ -1832,7 +1824,6 @@ public void Switch( System::Action newFloatingScalableMatrixWithTieredPricing, System::Action newFloatingCumulativeGroupedBulk, System::Action cumulativeGroupedAllocation, - System::Action minimum, System::Action newFloatingMinimumComposite, System::Action percent, System::Action eventOutput @@ -1924,9 +1915,6 @@ public void Switch( case PriceCumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case global::Orb.Models.Prices.PriceMinimum value: - minimum(value); - break; case NewFloatingMinimumCompositePrice value: newFloatingMinimumComposite(value); break; @@ -1984,7 +1972,6 @@ public void Switch( /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, /// (PriceCumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Prices.PriceMinimum value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, /// (PricePercent value) => {...}, /// (PriceEventOutput value) => {...} @@ -2036,7 +2023,6 @@ public T Match( > newFloatingScalableMatrixWithTieredPricing, System::Func newFloatingCumulativeGroupedBulk, System::Func cumulativeGroupedAllocation, - System::Func minimum, System::Func newFloatingMinimumComposite, System::Func percent, System::Func eventOutput @@ -2079,7 +2065,6 @@ public T Match( newFloatingScalableMatrixWithTieredPricing(value), NewFloatingCumulativeGroupedBulkPrice value => newFloatingCumulativeGroupedBulk(value), PriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - global::Orb.Models.Prices.PriceMinimum value => minimum(value), NewFloatingMinimumCompositePrice value => newFloatingMinimumComposite(value), PricePercent value => percent(value), PriceEventOutput value => eventOutput(value), @@ -2087,126 +2072,76 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Prices.Price(NewFloatingUnitPrice value) => - new(value); - - public static implicit operator global::Orb.Models.Prices.Price(NewFloatingTieredPrice value) => - new(value); + public static implicit operator Price(NewFloatingUnitPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(NewFloatingBulkPrice value) => - new(value); + public static implicit operator Price(NewFloatingTieredPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(PriceBulkWithFilters value) => - new(value); + public static implicit operator Price(NewFloatingBulkPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingPackagePrice value - ) => new(value); + public static implicit operator Price(PriceBulkWithFilters value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(NewFloatingMatrixPrice value) => - new(value); + public static implicit operator Price(NewFloatingPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingThresholdTotalAmountPrice value - ) => new(value); + public static implicit operator Price(NewFloatingMatrixPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewFloatingThresholdTotalAmountPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingTieredWithMinimumPrice value - ) => new(value); + public static implicit operator Price(NewFloatingTieredPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingGroupedTieredPrice value - ) => new(value); + public static implicit operator Price(NewFloatingTieredWithMinimumPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingTieredPackageWithMinimumPrice value - ) => new(value); + public static implicit operator Price(NewFloatingGroupedTieredPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingPackageWithAllocationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingTieredPackageWithMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingUnitWithPercentPrice value - ) => new(value); + public static implicit operator Price(NewFloatingPackageWithAllocationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingMatrixWithAllocationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingUnitWithPercentPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingTieredWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingMatrixWithAllocationPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingUnitWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingTieredWithProrationPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingGroupedAllocationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingUnitWithProrationPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingBulkWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingGroupedAllocationPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingGroupedWithProratedMinimumPrice value - ) => new(value); + public static implicit operator Price(NewFloatingBulkWithProrationPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingGroupedWithMeteredMinimumPrice value - ) => new(value); + public static implicit operator Price(NewFloatingGroupedWithProratedMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - PriceGroupedWithMinMaxThresholds value - ) => new(value); + public static implicit operator Price(NewFloatingGroupedWithMeteredMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingMatrixWithDisplayNamePrice value - ) => new(value); + public static implicit operator Price(PriceGroupedWithMinMaxThresholds value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingGroupedTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewFloatingMatrixWithDisplayNamePrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingMaxGroupTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewFloatingGroupedTieredPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingScalableMatrixWithUnitPricingPrice value - ) => new(value); + public static implicit operator Price(NewFloatingMaxGroupTieredPackagePrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingScalableMatrixWithTieredPricingPrice value - ) => new(value); + public static implicit operator Price(NewFloatingScalableMatrixWithUnitPricingPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingCumulativeGroupedBulkPrice value - ) => new(value); + public static implicit operator Price(NewFloatingScalableMatrixWithTieredPricingPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - PriceCumulativeGroupedAllocation value - ) => new(value); + public static implicit operator Price(NewFloatingCumulativeGroupedBulkPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - global::Orb.Models.Prices.PriceMinimum value - ) => new(value); + public static implicit operator Price(PriceCumulativeGroupedAllocation value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingMinimumCompositePrice value - ) => new(value); + public static implicit operator Price(NewFloatingMinimumCompositePrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(PricePercent value) => - new(value); + public static implicit operator Price(PricePercent value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(PriceEventOutput value) => - new(value); + public static implicit operator Price(PriceEventOutput value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2257,14 +2192,13 @@ public override void Validate() newFloatingScalableMatrixWithTieredPricing.Validate(), (newFloatingCumulativeGroupedBulk) => newFloatingCumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), (newFloatingMinimumComposite) => newFloatingMinimumComposite.Validate(), (percent) => percent.Validate(), (eventOutput) => eventOutput.Validate() ); } - public virtual bool Equals(global::Orb.Models.Prices.Price? other) + public virtual bool Equals(Price? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -2278,9 +2212,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class PriceConverter : JsonConverter +sealed class PriceConverter : JsonConverter { - public override global::Orb.Models.Prices.Price? Read( + public override Price? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -2932,29 +2866,6 @@ JsonSerializerOptions options return new(element); } - case "minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } case "minimum_composite": { try @@ -3020,16 +2931,12 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Prices.Price(element); + return new Price(element); } } } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Prices.Price? value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Price? value, JsonSerializerOptions options) { JsonSerializer.Serialize(writer, value?.Json, options); } @@ -5547,757 +5454,6 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.PriceMinimum, - global::Orb.Models.Prices.PriceMinimumFromRaw - >) -)] -public sealed record class PriceMinimum : JsonModel -{ - /// - /// The cadence to bill for this price on. - /// - public required ApiEnum Cadence - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); - } - init { this._rawData.Set("cadence", value); } - } - - /// - /// An ISO 4217 currency string for which this price is billed in. - /// - public required string Currency - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("currency"); - } - init { this._rawData.Set("currency", value); } - } - - /// - /// The id of the item the price will be associated with. - /// - public required string ItemID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); - } - init { this._rawData.Set("item_id", value); } - } - - /// - /// Configuration for minimum pricing - /// - public required PriceMinimumMinimumConfig MinimumConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_config"); - } - init { this._rawData.Set("minimum_config", value); } - } - - /// - /// The pricing model type - /// - public JsonElement ModelType - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); - } - init { this._rawData.Set("model_type", value); } - } - - /// - /// The name of the price. - /// - public required string Name - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } - } - - /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. - /// - public string? BillableMetricID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); - } - init { this._rawData.Set("billable_metric_id", value); } - } - - /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. - /// - public bool? BilledInAdvance - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); - } - init { this._rawData.Set("billed_in_advance", value); } - } - - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } - } - - /// - /// The per unit conversion rate of the price currency to the invoicing currency. - /// - public double? ConversionRate - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); - } - init { this._rawData.Set("conversion_rate", value); } - } - - /// - /// The configuration for the rate of the price currency to the invoicing currency. - /// - public global::Orb.Models.Prices.PriceMinimumConversionRateConfig? ConversionRateConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", value); } - } - - /// - /// For dimensional price: specifies a price group and dimension values - /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } - } - - /// - /// An alias for the price. - /// - public string? ExternalPriceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } - } - - /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. - /// - public double? FixedPriceQuantity - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } - } - - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", value); } - } - - /// - /// Within each billing cycle, specifies the cadence at which invoices are produced. - /// If unspecified, a single invoice is produced per billing cycle. - /// - public NewBillingCycleConfiguration? InvoicingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); - } - init { this._rawData.Set("invoicing_cycle_configuration", value); } - } - - /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared - /// by setting `metadata` to `null`. - /// - public IReadOnlyDictionary? Metadata - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) - ); - } - } - - /// - public override void Validate() - { - this.Cadence.Validate(); - _ = this.Currency; - _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) - { - throw new OrbInvalidDataException("Invalid value given for constant"); - } - _ = this.Name; - _ = this.BillableMetricID; - _ = this.BilledInAdvance; - this.BillingCycleConfiguration?.Validate(); - _ = this.ConversionRate; - this.ConversionRateConfig?.Validate(); - this.DimensionalPriceConfiguration?.Validate(); - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.InvoiceGroupingKey; - this.InvoicingCycleConfiguration?.Validate(); - _ = this.Metadata; - } - - public PriceMinimum() - { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); - } - - public PriceMinimum(global::Orb.Models.Prices.PriceMinimum priceMinimum) - : base(priceMinimum) { } - - public PriceMinimum(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("minimum"); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - PriceMinimum(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static global::Orb.Models.Prices.PriceMinimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class PriceMinimumFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Prices.PriceMinimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.PriceMinimum.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(global::Orb.Models.Prices.PriceMinimumCadenceConverter))] -public enum PriceMinimumCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class PriceMinimumCadenceConverter - : JsonConverter -{ - public override global::Orb.Models.Prices.PriceMinimumCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => global::Orb.Models.Prices.PriceMinimumCadence.Annual, - "semi_annual" => global::Orb.Models.Prices.PriceMinimumCadence.SemiAnnual, - "monthly" => global::Orb.Models.Prices.PriceMinimumCadence.Monthly, - "quarterly" => global::Orb.Models.Prices.PriceMinimumCadence.Quarterly, - "one_time" => global::Orb.Models.Prices.PriceMinimumCadence.OneTime, - "custom" => global::Orb.Models.Prices.PriceMinimumCadence.Custom, - _ => (global::Orb.Models.Prices.PriceMinimumCadence)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Prices.PriceMinimumCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - global::Orb.Models.Prices.PriceMinimumCadence.Annual => "annual", - global::Orb.Models.Prices.PriceMinimumCadence.SemiAnnual => "semi_annual", - global::Orb.Models.Prices.PriceMinimumCadence.Monthly => "monthly", - global::Orb.Models.Prices.PriceMinimumCadence.Quarterly => "quarterly", - global::Orb.Models.Prices.PriceMinimumCadence.OneTime => "one_time", - global::Orb.Models.Prices.PriceMinimumCadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} - -/// -/// Configuration for minimum pricing -/// -[JsonConverter( - typeof(JsonModelConverter) -)] -public sealed record class PriceMinimumMinimumConfig : JsonModel -{ - /// - /// The minimum amount to apply - /// - public required string MinimumAmount - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); - } - init { this._rawData.Set("minimum_amount", value); } - } - - /// - /// If true, subtotals from this price are prorated based on the service period - /// - public bool? Prorated - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); - } - init - { - if (value == null) - { - return; - } - - this._rawData.Set("prorated", value); - } - } - - /// - public override void Validate() - { - _ = this.MinimumAmount; - _ = this.Prorated; - } - - public PriceMinimumMinimumConfig() { } - - public PriceMinimumMinimumConfig(PriceMinimumMinimumConfig priceMinimumMinimumConfig) - : base(priceMinimumMinimumConfig) { } - - public PriceMinimumMinimumConfig(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - PriceMinimumMinimumConfig(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static PriceMinimumMinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public PriceMinimumMinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } -} - -class PriceMinimumMinimumConfigFromRaw : IFromRawJson -{ - /// - public PriceMinimumMinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => PriceMinimumMinimumConfig.FromRawUnchecked(rawData); -} - -[JsonConverter(typeof(global::Orb.Models.Prices.PriceMinimumConversionRateConfigConverter))] -public record class PriceMinimumConversionRateConfig : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - - public JsonElement Json - { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } - } - - public PriceMinimumConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public PriceMinimumConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public PriceMinimumConversionRateConfig(JsonElement element) - { - this._element = element; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) - { - value = this.Value as SharedUnitConversionRateConfig; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) - { - value = this.Value as SharedTieredConversionRateConfig; - return value != null; - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action unit, - System::Action tiered - ) - { - switch (this.Value) - { - case SharedUnitConversionRateConfig value: - unit(value); - break; - case SharedTieredConversionRateConfig value: - tiered(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of PriceMinimumConversionRateConfig" - ); - } - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func unit, - System::Func tiered - ) - { - return this.Value switch - { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of PriceMinimumConversionRateConfig" - ), - }; - } - - public static implicit operator global::Orb.Models.Prices.PriceMinimumConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); - - public static implicit operator global::Orb.Models.Prices.PriceMinimumConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); - - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() - { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of PriceMinimumConversionRateConfig" - ); - } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); - } - - public virtual bool Equals(global::Orb.Models.Prices.PriceMinimumConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } - - public override int GetHashCode() - { - return 0; - } - - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class PriceMinimumConversionRateConfigConverter - : JsonConverter -{ - public override global::Orb.Models.Prices.PriceMinimumConversionRateConfig? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; - try - { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); - } - catch - { - conversionRateType = null; - } - - switch (conversionRateType) - { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new global::Orb.Models.Prices.PriceMinimumConversionRateConfig(element); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Prices.PriceMinimumConversionRateConfig value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } -} - [JsonConverter(typeof(JsonModelConverter))] public sealed record class PricePercent : JsonModel { diff --git a/src/Orb/Models/Prices/PriceEvaluateParams.cs b/src/Orb/Models/Prices/PriceEvaluateParams.cs index 84d73a41..c3aa1822 100644 --- a/src/Orb/Models/Prices/PriceEvaluateParams.cs +++ b/src/Orb/Models/Prices/PriceEvaluateParams.cs @@ -34,8 +34,12 @@ namespace Orb.Models.Prices; /// and the length of the results must be no greater than 1000. Note that this is /// a POST endpoint rather than a GET endpoint because it employs a JSON body rather /// than query parameters. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class PriceEvaluateParams : ParamsBase +public record class PriceEvaluateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -138,6 +142,8 @@ public IReadOnlyList? GroupingKeys public PriceEvaluateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluateParams(PriceEvaluateParams priceEvaluateParams) : base(priceEvaluateParams) { @@ -145,6 +151,7 @@ public PriceEvaluateParams(PriceEvaluateParams priceEvaluateParams) this._rawBodyData = new(priceEvaluateParams._rawBodyData); } +#pragma warning restore CS8618 public PriceEvaluateParams( IReadOnlyDictionary rawHeaderData, @@ -185,6 +192,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["PriceID"] = this.PriceID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(PriceEvaluateParams? other) + { + if (other == null) + { + return false; + } + return (this.PriceID?.Equals(other.PriceID) ?? other.PriceID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -213,4 +244,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs b/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs index 7e441a1e..4af11032 100644 --- a/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs +++ b/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs @@ -28,8 +28,12 @@ namespace Orb.Models.Prices; /// /// Note that this is a POST endpoint rather than a GET endpoint because it /// employs a JSON body rather than query parameters. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class PriceEvaluatePreviewEventsParams : ParamsBase +public record class PriceEvaluatePreviewEventsParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -141,6 +145,8 @@ public IReadOnlyList? PriceEval public PriceEvaluatePreviewEventsParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluatePreviewEventsParams( PriceEvaluatePreviewEventsParams priceEvaluatePreviewEventsParams ) @@ -148,6 +154,7 @@ PriceEvaluatePreviewEventsParams priceEvaluatePreviewEventsParams { this._rawBodyData = new(priceEvaluatePreviewEventsParams._rawBodyData); } +#pragma warning restore CS8618 public PriceEvaluatePreviewEventsParams( IReadOnlyDictionary rawHeaderData, @@ -188,6 +195,28 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(PriceEvaluatePreviewEventsParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -215,6 +244,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(JsonModelConverter))] @@ -530,7 +564,6 @@ public string Currency newFloatingScalableMatrixWithTieredPricing: (x) => x.Currency, newFloatingCumulativeGroupedBulk: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, newFloatingMinimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency @@ -571,7 +604,6 @@ public string ItemID newFloatingScalableMatrixWithTieredPricing: (x) => x.ItemID, newFloatingCumulativeGroupedBulk: (x) => x.ItemID, cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, newFloatingMinimumComposite: (x) => x.ItemID, percent: (x) => x.ItemID, eventOutput: (x) => x.ItemID @@ -612,7 +644,6 @@ public string Name newFloatingScalableMatrixWithTieredPricing: (x) => x.Name, newFloatingCumulativeGroupedBulk: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, newFloatingMinimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name @@ -653,7 +684,6 @@ public string? BillableMetricID newFloatingScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, newFloatingCumulativeGroupedBulk: (x) => x.BillableMetricID, cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, newFloatingMinimumComposite: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID @@ -694,7 +724,6 @@ public bool? BilledInAdvance newFloatingScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, newFloatingCumulativeGroupedBulk: (x) => x.BilledInAdvance, cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, newFloatingMinimumComposite: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance @@ -735,7 +764,6 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newFloatingScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, newFloatingCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, newFloatingMinimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration @@ -776,7 +804,6 @@ public double? ConversionRate newFloatingScalableMatrixWithTieredPricing: (x) => x.ConversionRate, newFloatingCumulativeGroupedBulk: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, newFloatingMinimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate @@ -817,7 +844,6 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration newFloatingScalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, newFloatingCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, newFloatingMinimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration @@ -858,7 +884,6 @@ public string? ExternalPriceID newFloatingScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, newFloatingCumulativeGroupedBulk: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, newFloatingMinimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID @@ -899,7 +924,6 @@ public double? FixedPriceQuantity newFloatingScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, newFloatingCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, newFloatingMinimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity @@ -940,7 +964,6 @@ public string? InvoiceGroupingKey newFloatingScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, newFloatingCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, newFloatingMinimumComposite: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey @@ -981,7 +1004,6 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration newFloatingScalableMatrixWithTieredPricing: (x) => x.InvoicingCycleConfiguration, newFloatingCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, newFloatingMinimumComposite: (x) => x.InvoicingCycleConfiguration, percent: (x) => x.InvoicingCycleConfiguration, eventOutput: (x) => x.InvoicingCycleConfiguration @@ -1241,15 +1263,6 @@ public PriceEvaluatePreviewEventsParamsPriceEvaluationPrice( this._element = element; } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPrice( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPrice( NewFloatingMinimumCompositePrice value, JsonElement? element = null @@ -1923,29 +1936,6 @@ out PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocat return value != null; } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum( - [NotNullWhen(true)] out PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum? value - ) - { - value = this.Value as PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum; - return value != null; - } - /// /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . @@ -2058,7 +2048,6 @@ out PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput? value /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent value) => {...}, /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput value) => {...} @@ -2095,7 +2084,6 @@ public void Switch( System::Action newFloatingScalableMatrixWithTieredPricing, System::Action newFloatingCumulativeGroupedBulk, System::Action cumulativeGroupedAllocation, - System::Action minimum, System::Action newFloatingMinimumComposite, System::Action percent, System::Action eventOutput @@ -2187,9 +2175,6 @@ public void Switch( case PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum value: - minimum(value); - break; case NewFloatingMinimumCompositePrice value: newFloatingMinimumComposite(value); break; @@ -2249,7 +2234,6 @@ public void Switch( /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent value) => {...}, /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput value) => {...} @@ -2310,7 +2294,6 @@ public T Match( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation, T > cumulativeGroupedAllocation, - System::Func minimum, System::Func newFloatingMinimumComposite, System::Func percent, System::Func eventOutput @@ -2356,7 +2339,6 @@ public T Match( NewFloatingCumulativeGroupedBulkPrice value => newFloatingCumulativeGroupedBulk(value), PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum value => minimum(value), NewFloatingMinimumCompositePrice value => newFloatingMinimumComposite(value), PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent value => percent(value), PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput value => eventOutput( @@ -2480,10 +2462,6 @@ public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationP PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation value ) => new(value); - public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPrice( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum value - ) => new(value); - public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPrice( NewFloatingMinimumCompositePrice value ) => new(value); @@ -2547,7 +2525,6 @@ public override void Validate() newFloatingScalableMatrixWithTieredPricing.Validate(), (newFloatingCumulativeGroupedBulk) => newFloatingCumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), (newFloatingMinimumComposite) => newFloatingMinimumComposite.Validate(), (percent) => percent.Validate(), (eventOutput) => eventOutput.Validate() @@ -3226,29 +3203,6 @@ JsonSerializerOptions options return new(element); } - case "minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } case "minimum_composite": { try @@ -6011,803 +5965,6 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumFromRaw - >) -)] -public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum : JsonModel -{ - /// - /// The cadence to bill for this price on. - /// - public required ApiEnum< - string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence - > Cadence - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); - } - init { this._rawData.Set("cadence", value); } - } - - /// - /// An ISO 4217 currency string for which this price is billed in. - /// - public required string Currency - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("currency"); - } - init { this._rawData.Set("currency", value); } - } - - /// - /// The id of the item the price will be associated with. - /// - public required string ItemID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); - } - init { this._rawData.Set("item_id", value); } - } - - /// - /// Configuration for minimum pricing - /// - public required PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig MinimumConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" - ); - } - init { this._rawData.Set("minimum_config", value); } - } - - /// - /// The pricing model type - /// - public JsonElement ModelType - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); - } - init { this._rawData.Set("model_type", value); } - } - - /// - /// The name of the price. - /// - public required string Name - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } - } - - /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. - /// - public string? BillableMetricID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); - } - init { this._rawData.Set("billable_metric_id", value); } - } - - /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. - /// - public bool? BilledInAdvance - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); - } - init { this._rawData.Set("billed_in_advance", value); } - } - - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } - } - - /// - /// The per unit conversion rate of the price currency to the invoicing currency. - /// - public double? ConversionRate - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); - } - init { this._rawData.Set("conversion_rate", value); } - } - - /// - /// The configuration for the rate of the price currency to the invoicing currency. - /// - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig? ConversionRateConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", value); } - } - - /// - /// For dimensional price: specifies a price group and dimension values - /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } - } - - /// - /// An alias for the price. - /// - public string? ExternalPriceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } - } - - /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. - /// - public double? FixedPriceQuantity - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } - } - - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", value); } - } - - /// - /// Within each billing cycle, specifies the cadence at which invoices are produced. - /// If unspecified, a single invoice is produced per billing cycle. - /// - public NewBillingCycleConfiguration? InvoicingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); - } - init { this._rawData.Set("invoicing_cycle_configuration", value); } - } - - /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared - /// by setting `metadata` to `null`. - /// - public IReadOnlyDictionary? Metadata - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) - ); - } - } - - /// - public override void Validate() - { - this.Cadence.Validate(); - _ = this.Currency; - _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) - { - throw new OrbInvalidDataException("Invalid value given for constant"); - } - _ = this.Name; - _ = this.BillableMetricID; - _ = this.BilledInAdvance; - this.BillingCycleConfiguration?.Validate(); - _ = this.ConversionRate; - this.ConversionRateConfig?.Validate(); - this.DimensionalPriceConfiguration?.Validate(); - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.InvoiceGroupingKey; - this.InvoicingCycleConfiguration?.Validate(); - _ = this.Metadata; - } - - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum() - { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); - } - - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum priceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum - ) - : base(priceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum) { } - - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("minimum"); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumFromRaw - : IFromRawJson -{ - /// - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) => PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadenceConverter))] -public enum PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadenceConverter - : JsonConverter -{ - public override PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, - "semi_annual" => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.SemiAnnual, - "monthly" => PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Monthly, - "quarterly" => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Quarterly, - "one_time" => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.OneTime, - "custom" => PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Custom, - _ => (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual => - "annual", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.SemiAnnual => - "semi_annual", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Monthly => - "monthly", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Quarterly => - "quarterly", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.OneTime => - "one_time", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Custom => - "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} - -/// -/// Configuration for minimum pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfigFromRaw - >) -)] -public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig - : JsonModel -{ - /// - /// The minimum amount to apply - /// - public required string MinimumAmount - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); - } - init { this._rawData.Set("minimum_amount", value); } - } - - /// - /// If true, subtotals from this price are prorated based on the service period - /// - public bool? Prorated - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); - } - init - { - if (value == null) - { - return; - } - - this._rawData.Set("prorated", value); - } - } - - /// - public override void Validate() - { - _ = this.MinimumAmount; - _ = this.Prorated; - } - - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig() { } - - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig priceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig - ) - : base(priceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig) { } - - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig( - string minimumAmount - ) - : this() - { - this.MinimumAmount = minimumAmount; - } -} - -class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfigFromRaw - : IFromRawJson -{ - /// - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig.FromRawUnchecked( - rawData - ); -} - -[JsonConverter( - typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfigConverter) -)] -public record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig - : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - - public JsonElement Json - { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } - } - - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig( - JsonElement element - ) - { - this._element = element; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) - { - value = this.Value as SharedUnitConversionRateConfig; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) - { - value = this.Value as SharedTieredConversionRateConfig; - return value != null; - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action unit, - System::Action tiered - ) - { - switch (this.Value) - { - case SharedUnitConversionRateConfig value: - unit(value); - break; - case SharedTieredConversionRateConfig value: - tiered(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig" - ); - } - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func unit, - System::Func tiered - ) - { - return this.Value switch - { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig" - ), - }; - } - - public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); - - public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); - - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() - { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig" - ); - } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); - } - - public virtual bool Equals( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } - - public override int GetHashCode() - { - return 0; - } - - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfigConverter - : JsonConverter -{ - public override PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; - try - { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); - } - catch - { - conversionRateType = null; - } - - switch (conversionRateType) - { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig( - element - ); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } -} - [JsonConverter( typeof(JsonModelConverter< PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent, diff --git a/src/Orb/Models/Prices/PriceFetchParams.cs b/src/Orb/Models/Prices/PriceFetchParams.cs index 8b842a32..e6bb466a 100644 --- a/src/Orb/Models/Prices/PriceFetchParams.cs +++ b/src/Orb/Models/Prices/PriceFetchParams.cs @@ -10,18 +10,25 @@ namespace Orb.Models.Prices; /// /// This endpoint returns a price given an identifier. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class PriceFetchParams : ParamsBase +public record class PriceFetchParams : ParamsBase { public string? PriceID { get; init; } public PriceFetchParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceFetchParams(PriceFetchParams priceFetchParams) : base(priceFetchParams) { this.PriceID = priceFetchParams.PriceID; } +#pragma warning restore CS8618 public PriceFetchParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["PriceID"] = this.PriceID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(PriceFetchParams? other) + { + if (other == null) + { + return false; + } + return (this.PriceID?.Equals(other.PriceID) ?? other.PriceID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -74,4 +103,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Prices/PriceListParams.cs b/src/Orb/Models/Prices/PriceListParams.cs index 8b29225f..a37eb948 100644 --- a/src/Orb/Models/Prices/PriceListParams.cs +++ b/src/Orb/Models/Prices/PriceListParams.cs @@ -10,8 +10,12 @@ namespace Orb.Models.Prices; /// /// This endpoint is used to list all add-on prices created using the [price creation endpoint](/api-reference/price/create-price). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class PriceListParams : ParamsBase +public record class PriceListParams : ParamsBase { /// /// Cursor for pagination. This can be populated by the `next_cursor` value returned @@ -50,8 +54,11 @@ public long? Limit public PriceListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceListParams(PriceListParams priceListParams) : base(priceListParams) { } +#pragma warning restore CS8618 public PriceListParams( IReadOnlyDictionary rawHeaderData, @@ -86,6 +93,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(PriceListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/prices") @@ -102,4 +129,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Prices/PriceUpdateParams.cs b/src/Orb/Models/Prices/PriceUpdateParams.cs index 4b06f3b1..8d4b9c21 100644 --- a/src/Orb/Models/Prices/PriceUpdateParams.cs +++ b/src/Orb/Models/Prices/PriceUpdateParams.cs @@ -12,8 +12,12 @@ namespace Orb.Models.Prices; /// /// This endpoint allows you to update the `metadata` property on a price. If you /// pass null for the metadata value, it will clear any existing metadata for that price. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class PriceUpdateParams : ParamsBase +public record class PriceUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -48,6 +52,8 @@ public IReadOnlyDictionary RawBodyData public PriceUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceUpdateParams(PriceUpdateParams priceUpdateParams) : base(priceUpdateParams) { @@ -55,6 +61,7 @@ public PriceUpdateParams(PriceUpdateParams priceUpdateParams) this._rawBodyData = new(priceUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public PriceUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -95,6 +102,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["PriceID"] = this.PriceID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(PriceUpdateParams? other) + { + if (other == null) + { + return false; + } + return (this.PriceID?.Equals(other.PriceID) ?? other.PriceID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -122,4 +153,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeApplyParams.cs b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeApplyParams.cs index 3c67a0f9..04d739ee 100644 --- a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeApplyParams.cs +++ b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeApplyParams.cs @@ -13,8 +13,12 @@ namespace Orb.Models.SubscriptionChanges; /// 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. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionChangeApplyParams : ParamsBase +public record class SubscriptionChangeApplyParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -108,6 +112,8 @@ public string? PreviouslyCollectedAmount public SubscriptionChangeApplyParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionChangeApplyParams( SubscriptionChangeApplyParams subscriptionChangeApplyParams ) @@ -117,6 +123,7 @@ SubscriptionChangeApplyParams subscriptionChangeApplyParams this._rawBodyData = new(subscriptionChangeApplyParams._rawBodyData); } +#pragma warning restore CS8618 public SubscriptionChangeApplyParams( IReadOnlyDictionary rawHeaderData, @@ -157,6 +164,33 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["SubscriptionChangeID"] = this.SubscriptionChangeID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionChangeApplyParams? other) + { + if (other == null) + { + return false; + } + return ( + this.SubscriptionChangeID?.Equals(other.SubscriptionChangeID) + ?? other.SubscriptionChangeID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -185,4 +219,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeCancelParams.cs b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeCancelParams.cs index d13c4738..dd84813b 100644 --- a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeCancelParams.cs +++ b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeCancelParams.cs @@ -12,13 +12,19 @@ namespace Orb.Models.SubscriptionChanges; /// 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. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionChangeCancelParams : ParamsBase +public record class SubscriptionChangeCancelParams : ParamsBase { public string? SubscriptionChangeID { get; init; } public SubscriptionChangeCancelParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionChangeCancelParams( SubscriptionChangeCancelParams subscriptionChangeCancelParams ) @@ -26,6 +32,7 @@ SubscriptionChangeCancelParams subscriptionChangeCancelParams { this.SubscriptionChangeID = subscriptionChangeCancelParams.SubscriptionChangeID; } +#pragma warning restore CS8618 public SubscriptionChangeCancelParams( IReadOnlyDictionary rawHeaderData, @@ -60,6 +67,31 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["SubscriptionChangeID"] = this.SubscriptionChangeID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionChangeCancelParams? other) + { + if (other == null) + { + return false; + } + return ( + this.SubscriptionChangeID?.Equals(other.SubscriptionChangeID) + ?? other.SubscriptionChangeID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -79,4 +111,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListParams.cs b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListParams.cs index 943363b6..d6730c4e 100644 --- a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListParams.cs +++ b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListParams.cs @@ -14,8 +14,12 @@ namespace Orb.Models.SubscriptionChanges; /// This endpoint returns a list of pending subscription changes for a customer. /// Use the [Fetch Subscription Change](fetch-subscription-change) endpoint to retrieve /// the expected subscription state after the pending change is applied. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionChangeListParams : ParamsBase +public record class SubscriptionChangeListParams : ParamsBase { /// /// Cursor for pagination. This can be populated by the `next_cursor` value returned @@ -72,22 +76,23 @@ public long? Limit } } - public ApiEnum? Status + public ApiEnum? Status { get { this._rawQueryData.Freeze(); - return this._rawQueryData.GetNullableClass< - ApiEnum - >("status"); + return this._rawQueryData.GetNullableClass>("status"); } init { this._rawQueryData.Set("status", value); } } public SubscriptionChangeListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionChangeListParams(SubscriptionChangeListParams subscriptionChangeListParams) : base(subscriptionChangeListParams) { } +#pragma warning restore CS8618 public SubscriptionChangeListParams( IReadOnlyDictionary rawHeaderData, @@ -122,6 +127,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionChangeListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -140,9 +165,14 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } -[JsonConverter(typeof(global::Orb.Models.SubscriptionChanges.StatusConverter))] +[JsonConverter(typeof(StatusConverter))] public enum Status { Pending, @@ -150,9 +180,9 @@ public enum Status Cancelled, } -sealed class StatusConverter : JsonConverter +sealed class StatusConverter : JsonConverter { - public override global::Orb.Models.SubscriptionChanges.Status Read( + public override Status Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -160,26 +190,22 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "pending" => global::Orb.Models.SubscriptionChanges.Status.Pending, - "applied" => global::Orb.Models.SubscriptionChanges.Status.Applied, - "cancelled" => global::Orb.Models.SubscriptionChanges.Status.Cancelled, - _ => (global::Orb.Models.SubscriptionChanges.Status)(-1), + "pending" => Status.Pending, + "applied" => Status.Applied, + "cancelled" => Status.Cancelled, + _ => (Status)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.SubscriptionChanges.Status value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.SubscriptionChanges.Status.Pending => "pending", - global::Orb.Models.SubscriptionChanges.Status.Applied => "applied", - global::Orb.Models.SubscriptionChanges.Status.Cancelled => "cancelled", + Status.Pending => "pending", + Status.Applied => "applied", + Status.Cancelled => "cancelled", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeRetrieveParams.cs b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeRetrieveParams.cs index 3f49c327..63cc31aa 100644 --- a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeRetrieveParams.cs +++ b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeRetrieveParams.cs @@ -16,13 +16,19 @@ namespace Orb.Models.SubscriptionChanges; /// 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. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionChangeRetrieveParams : ParamsBase +public record class SubscriptionChangeRetrieveParams : ParamsBase { public string? SubscriptionChangeID { get; init; } public SubscriptionChangeRetrieveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionChangeRetrieveParams( SubscriptionChangeRetrieveParams subscriptionChangeRetrieveParams ) @@ -30,6 +36,7 @@ SubscriptionChangeRetrieveParams subscriptionChangeRetrieveParams { this.SubscriptionChangeID = subscriptionChangeRetrieveParams.SubscriptionChangeID; } +#pragma warning restore CS8618 public SubscriptionChangeRetrieveParams( IReadOnlyDictionary rawHeaderData, @@ -64,6 +71,31 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["SubscriptionChangeID"] = this.SubscriptionChangeID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionChangeRetrieveParams? other) + { + if (other == null) + { + return false; + } + return ( + this.SubscriptionChangeID?.Equals(other.SubscriptionChangeID) + ?? other.SubscriptionChangeID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -83,4 +115,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Subscriptions/DiscountOverride.cs b/src/Orb/Models/Subscriptions/DiscountOverride.cs index 642d8032..a160cbe7 100644 --- a/src/Orb/Models/Subscriptions/DiscountOverride.cs +++ b/src/Orb/Models/Subscriptions/DiscountOverride.cs @@ -12,14 +12,12 @@ namespace Orb.Models.Subscriptions; [JsonConverter(typeof(JsonModelConverter))] public sealed record class DiscountOverride : JsonModel { - public required ApiEnum DiscountType + public required ApiEnum DiscountType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("discount_type"); + return this._rawData.GetNotNullClass>("discount_type"); } init { this._rawData.Set("discount_type", value); } } @@ -101,9 +99,7 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public DiscountOverride( - ApiEnum discountType - ) + public DiscountOverride(ApiEnum discountType) : this() { this.DiscountType = discountType; @@ -117,7 +113,7 @@ public DiscountOverride FromRawUnchecked(IReadOnlyDictionary +sealed class DiscountTypeConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.DiscountType Read( + public override DiscountType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -135,16 +131,16 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "percentage" => global::Orb.Models.Subscriptions.DiscountType.Percentage, - "usage" => global::Orb.Models.Subscriptions.DiscountType.Usage, - "amount" => global::Orb.Models.Subscriptions.DiscountType.Amount, - _ => (global::Orb.Models.Subscriptions.DiscountType)(-1), + "percentage" => DiscountType.Percentage, + "usage" => DiscountType.Usage, + "amount" => DiscountType.Amount, + _ => (DiscountType)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.DiscountType value, + DiscountType value, JsonSerializerOptions options ) { @@ -152,9 +148,9 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Subscriptions.DiscountType.Percentage => "percentage", - global::Orb.Models.Subscriptions.DiscountType.Usage => "usage", - global::Orb.Models.Subscriptions.DiscountType.Amount => "amount", + DiscountType.Percentage => "percentage", + DiscountType.Usage => "usage", + DiscountType.Amount => "amount", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionBulkPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionBulkPrice.cs index 5689bada..74a121d1 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionBulkPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionBulkPrice.cs @@ -58,14 +58,12 @@ public required string ItemID /// /// The pricing model type /// - public required ApiEnum ModelType + public required ApiEnum ModelType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("model_type"); + return this._rawData.GetNotNullClass>("model_type"); } init { this._rawData.Set("model_type", value); } } @@ -394,15 +392,15 @@ JsonSerializerOptions options /// /// The pricing model type /// -[JsonConverter(typeof(global::Orb.Models.Subscriptions.ModelTypeConverter))] +[JsonConverter(typeof(ModelTypeConverter))] public enum ModelType { Bulk, } -sealed class ModelTypeConverter : JsonConverter +sealed class ModelTypeConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.ModelType Read( + public override ModelType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -410,14 +408,14 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "bulk" => global::Orb.Models.Subscriptions.ModelType.Bulk, - _ => (global::Orb.Models.Subscriptions.ModelType)(-1), + "bulk" => ModelType.Bulk, + _ => (ModelType)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.ModelType value, + ModelType value, JsonSerializerOptions options ) { @@ -425,7 +423,7 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Subscriptions.ModelType.Bulk => "bulk", + ModelType.Bulk => "bulk", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionBulkWithProrationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionBulkWithProrationPrice.cs index dab88d87..2661dfa4 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionBulkWithProrationPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionBulkWithProrationPrice.cs @@ -21,12 +21,12 @@ public sealed record class NewSubscriptionBulkWithProrationPrice : JsonModel /// /// Configuration for bulk_with_proration pricing /// - public required global::Orb.Models.Subscriptions.BulkWithProrationConfig BulkWithProrationConfig + public required BulkWithProrationConfig BulkWithProrationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "bulk_with_proration_config" ); } @@ -343,12 +343,7 @@ IReadOnlyDictionary rawData /// /// Configuration for bulk_with_proration pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.BulkWithProrationConfig, - global::Orb.Models.Subscriptions.BulkWithProrationConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class BulkWithProrationConfig : JsonModel { /// @@ -383,9 +378,7 @@ public override void Validate() public BulkWithProrationConfig() { } - public BulkWithProrationConfig( - global::Orb.Models.Subscriptions.BulkWithProrationConfig bulkWithProrationConfig - ) + public BulkWithProrationConfig(BulkWithProrationConfig bulkWithProrationConfig) : base(bulkWithProrationConfig) { } public BulkWithProrationConfig(IReadOnlyDictionary rawData) @@ -401,8 +394,8 @@ public BulkWithProrationConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.BulkWithProrationConfig FromRawUnchecked( + /// + public static BulkWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -417,13 +410,12 @@ public BulkWithProrationConfig(IReadOnlyList tiers) } } -class BulkWithProrationConfigFromRaw - : IFromRawJson +class BulkWithProrationConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.BulkWithProrationConfig FromRawUnchecked( + public BulkWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.BulkWithProrationConfig.FromRawUnchecked(rawData); + ) => BulkWithProrationConfig.FromRawUnchecked(rawData); } /// diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPrice.cs index fbc2978a..f3c60a36 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPrice.cs @@ -36,12 +36,12 @@ public required ApiEnum /// Configuration for cumulative_grouped_bulk pricing /// - public required global::Orb.Models.Subscriptions.CumulativeGroupedBulkConfig CumulativeGroupedBulkConfig + public required CumulativeGroupedBulkConfig CumulativeGroupedBulkConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "cumulative_grouped_bulk_config" ); } @@ -406,28 +406,25 @@ JsonSerializerOptions options /// Configuration for cumulative_grouped_bulk pricing /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.CumulativeGroupedBulkConfig, - global::Orb.Models.Subscriptions.CumulativeGroupedBulkConfigFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class CumulativeGroupedBulkConfig : JsonModel { /// /// Each tier lower bound must have the same group of values. /// - public required IReadOnlyList DimensionValues + public required IReadOnlyList DimensionValues { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("dimension_values"); + return this._rawData.GetNotNullStruct>( + "dimension_values" + ); } init { - this._rawData.Set>( + this._rawData.Set>( "dimension_values", ImmutableArray.ToImmutableArray(value) ); @@ -456,9 +453,7 @@ public override void Validate() public CumulativeGroupedBulkConfig() { } - public CumulativeGroupedBulkConfig( - global::Orb.Models.Subscriptions.CumulativeGroupedBulkConfig cumulativeGroupedBulkConfig - ) + public CumulativeGroupedBulkConfig(CumulativeGroupedBulkConfig cumulativeGroupedBulkConfig) : base(cumulativeGroupedBulkConfig) { } public CumulativeGroupedBulkConfig(IReadOnlyDictionary rawData) @@ -474,8 +469,8 @@ public CumulativeGroupedBulkConfig(IReadOnlyDictionary rawD } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.CumulativeGroupedBulkConfig FromRawUnchecked( + /// + public static CumulativeGroupedBulkConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -483,24 +478,18 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedBulkConfigFromRaw - : IFromRawJson +class CumulativeGroupedBulkConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.CumulativeGroupedBulkConfig FromRawUnchecked( + public CumulativeGroupedBulkConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.CumulativeGroupedBulkConfig.FromRawUnchecked(rawData); + ) => CumulativeGroupedBulkConfig.FromRawUnchecked(rawData); } /// /// Configuration for a dimension value entry /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.DimensionValue, - global::Orb.Models.Subscriptions.DimensionValueFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class DimensionValue : JsonModel { /// @@ -552,7 +541,7 @@ public override void Validate() public DimensionValue() { } - public DimensionValue(global::Orb.Models.Subscriptions.DimensionValue dimensionValue) + public DimensionValue(DimensionValue dimensionValue) : base(dimensionValue) { } public DimensionValue(IReadOnlyDictionary rawData) @@ -568,21 +557,18 @@ public DimensionValue(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.DimensionValue FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static DimensionValue FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class DimensionValueFromRaw : IFromRawJson +class DimensionValueFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.DimensionValue FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.DimensionValue.FromRawUnchecked(rawData); + public DimensionValue FromRawUnchecked(IReadOnlyDictionary rawData) => + DimensionValue.FromRawUnchecked(rawData); } /// diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedAllocationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedAllocationPrice.cs index 7d50e260..cb71dda2 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedAllocationPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedAllocationPrice.cs @@ -35,12 +35,12 @@ public required ApiEnum Ca /// /// Configuration for grouped_allocation pricing /// - public required global::Orb.Models.Subscriptions.GroupedAllocationConfig GroupedAllocationConfig + public required GroupedAllocationConfig GroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "grouped_allocation_config" ); } @@ -402,12 +402,7 @@ JsonSerializerOptions options /// /// Configuration for grouped_allocation pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.GroupedAllocationConfig, - global::Orb.Models.Subscriptions.GroupedAllocationConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class GroupedAllocationConfig : JsonModel { /// @@ -459,9 +454,7 @@ public override void Validate() public GroupedAllocationConfig() { } - public GroupedAllocationConfig( - global::Orb.Models.Subscriptions.GroupedAllocationConfig groupedAllocationConfig - ) + public GroupedAllocationConfig(GroupedAllocationConfig groupedAllocationConfig) : base(groupedAllocationConfig) { } public GroupedAllocationConfig(IReadOnlyDictionary rawData) @@ -477,8 +470,8 @@ public GroupedAllocationConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.GroupedAllocationConfig FromRawUnchecked( + /// + public static GroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -486,13 +479,12 @@ IReadOnlyDictionary rawData } } -class GroupedAllocationConfigFromRaw - : IFromRawJson +class GroupedAllocationConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.GroupedAllocationConfig FromRawUnchecked( + public GroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.GroupedAllocationConfig.FromRawUnchecked(rawData); + ) => GroupedAllocationConfig.FromRawUnchecked(rawData); } /// diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePrice.cs index cf689350..b4d29c04 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePrice.cs @@ -36,12 +36,12 @@ public required ApiEnum /// /// Configuration for grouped_tiered_package pricing /// - public required global::Orb.Models.Subscriptions.GroupedTieredPackageConfig GroupedTieredPackageConfig + public required GroupedTieredPackageConfig GroupedTieredPackageConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "grouped_tiered_package_config" ); } @@ -406,10 +406,7 @@ JsonSerializerOptions options /// Configuration for grouped_tiered_package pricing /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.GroupedTieredPackageConfig, - global::Orb.Models.Subscriptions.GroupedTieredPackageConfigFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class GroupedTieredPackageConfig : JsonModel { @@ -440,20 +437,21 @@ public required string PackageSize /// Apply tiered pricing after rounding up the quantity to the package size. /// Tiers are defined using exclusive lower bounds. /// - public required IReadOnlyList Tiers + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + return this._rawData.GetNotNullStruct>( + "tiers" + ); } init { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); } } @@ -470,9 +468,7 @@ public override void Validate() public GroupedTieredPackageConfig() { } - public GroupedTieredPackageConfig( - global::Orb.Models.Subscriptions.GroupedTieredPackageConfig groupedTieredPackageConfig - ) + public GroupedTieredPackageConfig(GroupedTieredPackageConfig groupedTieredPackageConfig) : base(groupedTieredPackageConfig) { } public GroupedTieredPackageConfig(IReadOnlyDictionary rawData) @@ -488,8 +484,8 @@ public GroupedTieredPackageConfig(IReadOnlyDictionary rawDa } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.GroupedTieredPackageConfig FromRawUnchecked( + /// + public static GroupedTieredPackageConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -497,13 +493,12 @@ IReadOnlyDictionary rawData } } -class GroupedTieredPackageConfigFromRaw - : IFromRawJson +class GroupedTieredPackageConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.GroupedTieredPackageConfig FromRawUnchecked( + public GroupedTieredPackageConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.GroupedTieredPackageConfig.FromRawUnchecked(rawData); + ) => GroupedTieredPackageConfig.FromRawUnchecked(rawData); } /// @@ -511,8 +506,8 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.GroupedTieredPackageConfigTier, - global::Orb.Models.Subscriptions.GroupedTieredPackageConfigTierFromRaw + GroupedTieredPackageConfigTier, + GroupedTieredPackageConfigTierFromRaw >) )] public sealed record class GroupedTieredPackageConfigTier : JsonModel @@ -550,7 +545,7 @@ public override void Validate() public GroupedTieredPackageConfigTier() { } public GroupedTieredPackageConfigTier( - global::Orb.Models.Subscriptions.GroupedTieredPackageConfigTier groupedTieredPackageConfigTier + GroupedTieredPackageConfigTier groupedTieredPackageConfigTier ) : base(groupedTieredPackageConfigTier) { } @@ -567,8 +562,8 @@ public GroupedTieredPackageConfigTier(IReadOnlyDictionary r } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.GroupedTieredPackageConfigTier FromRawUnchecked( + /// + public static GroupedTieredPackageConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -576,13 +571,12 @@ IReadOnlyDictionary rawData } } -class GroupedTieredPackageConfigTierFromRaw - : IFromRawJson +class GroupedTieredPackageConfigTierFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.GroupedTieredPackageConfigTier FromRawUnchecked( + public GroupedTieredPackageConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.GroupedTieredPackageConfigTier.FromRawUnchecked(rawData); + ) => GroupedTieredPackageConfigTier.FromRawUnchecked(rawData); } /// diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPrice.cs index 3f674426..577d98a6 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPrice.cs @@ -36,14 +36,12 @@ public required ApiEnum Cadenc /// /// Configuration for grouped_tiered pricing /// - public required global::Orb.Models.Subscriptions.GroupedTieredConfig GroupedTieredConfig + public required GroupedTieredConfig GroupedTieredConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_tiered_config" - ); + return this._rawData.GetNotNullClass("grouped_tiered_config"); } init { this._rawData.Set("grouped_tiered_config", value); } } @@ -402,12 +400,7 @@ JsonSerializerOptions options /// /// Configuration for grouped_tiered pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.GroupedTieredConfig, - global::Orb.Models.Subscriptions.GroupedTieredConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class GroupedTieredConfig : JsonModel { /// @@ -426,20 +419,19 @@ public required string GroupingKey /// /// Apply tiered pricing to each segment generated after grouping with the provided key /// - public required IReadOnlyList Tiers + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + return this._rawData.GetNotNullStruct>("tiers"); } init { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); } } @@ -455,9 +447,7 @@ public override void Validate() public GroupedTieredConfig() { } - public GroupedTieredConfig( - global::Orb.Models.Subscriptions.GroupedTieredConfig groupedTieredConfig - ) + public GroupedTieredConfig(GroupedTieredConfig groupedTieredConfig) : base(groupedTieredConfig) { } public GroupedTieredConfig(IReadOnlyDictionary rawData) @@ -473,8 +463,8 @@ public GroupedTieredConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.GroupedTieredConfig FromRawUnchecked( + /// + public static GroupedTieredConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -482,24 +472,17 @@ IReadOnlyDictionary rawData } } -class GroupedTieredConfigFromRaw - : IFromRawJson +class GroupedTieredConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.GroupedTieredConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.GroupedTieredConfig.FromRawUnchecked(rawData); + public GroupedTieredConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + GroupedTieredConfig.FromRawUnchecked(rawData); } /// /// Configuration for a single tier /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.GroupedTieredConfigTier, - global::Orb.Models.Subscriptions.GroupedTieredConfigTierFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class GroupedTieredConfigTier : JsonModel { public required string TierLowerBound @@ -534,9 +517,7 @@ public override void Validate() public GroupedTieredConfigTier() { } - public GroupedTieredConfigTier( - global::Orb.Models.Subscriptions.GroupedTieredConfigTier groupedTieredConfigTier - ) + public GroupedTieredConfigTier(GroupedTieredConfigTier groupedTieredConfigTier) : base(groupedTieredConfigTier) { } public GroupedTieredConfigTier(IReadOnlyDictionary rawData) @@ -552,8 +533,8 @@ public GroupedTieredConfigTier(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.GroupedTieredConfigTier FromRawUnchecked( + /// + public static GroupedTieredConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -561,13 +542,12 @@ IReadOnlyDictionary rawData } } -class GroupedTieredConfigTierFromRaw - : IFromRawJson +class GroupedTieredConfigTierFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.GroupedTieredConfigTier FromRawUnchecked( + public GroupedTieredConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.GroupedTieredConfigTier.FromRawUnchecked(rawData); + ) => GroupedTieredConfigTier.FromRawUnchecked(rawData); } /// diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPrice.cs index 42f09504..dedb7891 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPrice.cs @@ -36,12 +36,12 @@ public required ApiEnum /// Configuration for grouped_with_metered_minimum pricing /// - public required global::Orb.Models.Subscriptions.GroupedWithMeteredMinimumConfig GroupedWithMeteredMinimumConfig + public required GroupedWithMeteredMinimumConfig GroupedWithMeteredMinimumConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "grouped_with_metered_minimum_config" ); } @@ -410,8 +410,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.GroupedWithMeteredMinimumConfig, - global::Orb.Models.Subscriptions.GroupedWithMeteredMinimumConfigFromRaw + GroupedWithMeteredMinimumConfig, + GroupedWithMeteredMinimumConfigFromRaw >) )] public sealed record class GroupedWithMeteredMinimumConfig : JsonModel @@ -459,18 +459,16 @@ public required string PricingKey /// /// Scale the unit rates by the scaling factor. /// - public required IReadOnlyList ScalingFactors + public required IReadOnlyList ScalingFactors { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("scaling_factors"); + return this._rawData.GetNotNullStruct>("scaling_factors"); } init { - this._rawData.Set>( + this._rawData.Set>( "scaling_factors", ImmutableArray.ToImmutableArray(value) ); @@ -494,18 +492,16 @@ public required string ScalingKey /// Apply per unit pricing to each pricing value. The minimum amount is applied /// any unmatched usage. /// - public required IReadOnlyList UnitAmounts + public required IReadOnlyList UnitAmounts { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("unit_amounts"); + return this._rawData.GetNotNullStruct>("unit_amounts"); } init { - this._rawData.Set>( + this._rawData.Set>( "unit_amounts", ImmutableArray.ToImmutableArray(value) ); @@ -532,7 +528,7 @@ public override void Validate() public GroupedWithMeteredMinimumConfig() { } public GroupedWithMeteredMinimumConfig( - global::Orb.Models.Subscriptions.GroupedWithMeteredMinimumConfig groupedWithMeteredMinimumConfig + GroupedWithMeteredMinimumConfig groupedWithMeteredMinimumConfig ) : base(groupedWithMeteredMinimumConfig) { } @@ -549,8 +545,8 @@ public GroupedWithMeteredMinimumConfig(IReadOnlyDictionary } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.GroupedWithMeteredMinimumConfig FromRawUnchecked( + /// + public static GroupedWithMeteredMinimumConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -558,24 +554,18 @@ IReadOnlyDictionary rawData } } -class GroupedWithMeteredMinimumConfigFromRaw - : IFromRawJson +class GroupedWithMeteredMinimumConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.GroupedWithMeteredMinimumConfig FromRawUnchecked( + public GroupedWithMeteredMinimumConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.GroupedWithMeteredMinimumConfig.FromRawUnchecked(rawData); + ) => GroupedWithMeteredMinimumConfig.FromRawUnchecked(rawData); } /// /// Configuration for a scaling factor /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.ScalingFactor, - global::Orb.Models.Subscriptions.ScalingFactorFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class ScalingFactor : JsonModel { public required string ScalingFactorValue @@ -607,7 +597,7 @@ public override void Validate() public ScalingFactor() { } - public ScalingFactor(global::Orb.Models.Subscriptions.ScalingFactor scalingFactor) + public ScalingFactor(ScalingFactor scalingFactor) : base(scalingFactor) { } public ScalingFactor(IReadOnlyDictionary rawData) @@ -623,32 +613,24 @@ public ScalingFactor(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.ScalingFactor FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static ScalingFactor FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class ScalingFactorFromRaw : IFromRawJson +class ScalingFactorFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.ScalingFactor FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.ScalingFactor.FromRawUnchecked(rawData); + public ScalingFactor FromRawUnchecked(IReadOnlyDictionary rawData) => + ScalingFactor.FromRawUnchecked(rawData); } /// /// Configuration for a unit amount /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.UnitAmount, - global::Orb.Models.Subscriptions.UnitAmountFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class UnitAmount : JsonModel { public required string PricingValue @@ -683,7 +665,7 @@ public override void Validate() public UnitAmount() { } - public UnitAmount(global::Orb.Models.Subscriptions.UnitAmount unitAmount) + public UnitAmount(UnitAmount unitAmount) : base(unitAmount) { } public UnitAmount(IReadOnlyDictionary rawData) @@ -699,21 +681,18 @@ public UnitAmount(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.UnitAmount FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static UnitAmount FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class UnitAmountFromRaw : IFromRawJson +class UnitAmountFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.UnitAmount FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.UnitAmount.FromRawUnchecked(rawData); + public UnitAmount FromRawUnchecked(IReadOnlyDictionary rawData) => + UnitAmount.FromRawUnchecked(rawData); } /// diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPrice.cs index 77d37738..7180a9f9 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPrice.cs @@ -35,12 +35,12 @@ public required ApiEnum /// Configuration for grouped_with_prorated_minimum pricing /// - public required global::Orb.Models.Subscriptions.GroupedWithProratedMinimumConfig GroupedWithProratedMinimumConfig + public required GroupedWithProratedMinimumConfig GroupedWithProratedMinimumConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "grouped_with_prorated_minimum_config" ); } @@ -409,8 +409,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.GroupedWithProratedMinimumConfig, - global::Orb.Models.Subscriptions.GroupedWithProratedMinimumConfigFromRaw + GroupedWithProratedMinimumConfig, + GroupedWithProratedMinimumConfigFromRaw >) )] public sealed record class GroupedWithProratedMinimumConfig : JsonModel @@ -465,7 +465,7 @@ public override void Validate() public GroupedWithProratedMinimumConfig() { } public GroupedWithProratedMinimumConfig( - global::Orb.Models.Subscriptions.GroupedWithProratedMinimumConfig groupedWithProratedMinimumConfig + GroupedWithProratedMinimumConfig groupedWithProratedMinimumConfig ) : base(groupedWithProratedMinimumConfig) { } @@ -482,8 +482,8 @@ public GroupedWithProratedMinimumConfig(IReadOnlyDictionary } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.GroupedWithProratedMinimumConfig FromRawUnchecked( + /// + public static GroupedWithProratedMinimumConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -491,14 +491,12 @@ IReadOnlyDictionary rawData } } -class GroupedWithProratedMinimumConfigFromRaw - : IFromRawJson +class GroupedWithProratedMinimumConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.GroupedWithProratedMinimumConfig FromRawUnchecked( + public GroupedWithProratedMinimumConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Subscriptions.GroupedWithProratedMinimumConfig.FromRawUnchecked(rawData); + ) => GroupedWithProratedMinimumConfig.FromRawUnchecked(rawData); } /// diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePrice.cs index 6f2c5880..5436dbab 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePrice.cs @@ -49,12 +49,12 @@ public required string ItemID /// /// Configuration for matrix_with_display_name pricing /// - public required global::Orb.Models.Subscriptions.MatrixWithDisplayNameConfig MatrixWithDisplayNameConfig + public required MatrixWithDisplayNameConfig MatrixWithDisplayNameConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "matrix_with_display_name_config" ); } @@ -406,10 +406,7 @@ JsonSerializerOptions options /// Configuration for matrix_with_display_name pricing /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.MatrixWithDisplayNameConfig, - global::Orb.Models.Subscriptions.MatrixWithDisplayNameConfigFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class MatrixWithDisplayNameConfig : JsonModel { @@ -429,20 +426,21 @@ public required string Dimension /// /// Apply per unit pricing to each dimension value /// - public required IReadOnlyList UnitAmounts + public required IReadOnlyList UnitAmounts { get { this._rawData.Freeze(); return this._rawData.GetNotNullStruct< - ImmutableArray + ImmutableArray >("unit_amounts"); } init { - this._rawData.Set< - ImmutableArray - >("unit_amounts", ImmutableArray.ToImmutableArray(value)); + this._rawData.Set>( + "unit_amounts", + ImmutableArray.ToImmutableArray(value) + ); } } @@ -458,9 +456,7 @@ public override void Validate() public MatrixWithDisplayNameConfig() { } - public MatrixWithDisplayNameConfig( - global::Orb.Models.Subscriptions.MatrixWithDisplayNameConfig matrixWithDisplayNameConfig - ) + public MatrixWithDisplayNameConfig(MatrixWithDisplayNameConfig matrixWithDisplayNameConfig) : base(matrixWithDisplayNameConfig) { } public MatrixWithDisplayNameConfig(IReadOnlyDictionary rawData) @@ -476,8 +472,8 @@ public MatrixWithDisplayNameConfig(IReadOnlyDictionary rawD } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.MatrixWithDisplayNameConfig FromRawUnchecked( + /// + public static MatrixWithDisplayNameConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -485,13 +481,12 @@ IReadOnlyDictionary rawData } } -class MatrixWithDisplayNameConfigFromRaw - : IFromRawJson +class MatrixWithDisplayNameConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.MatrixWithDisplayNameConfig FromRawUnchecked( + public MatrixWithDisplayNameConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.MatrixWithDisplayNameConfig.FromRawUnchecked(rawData); + ) => MatrixWithDisplayNameConfig.FromRawUnchecked(rawData); } /// @@ -499,8 +494,8 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.MatrixWithDisplayNameConfigUnitAmount, - global::Orb.Models.Subscriptions.MatrixWithDisplayNameConfigUnitAmountFromRaw + MatrixWithDisplayNameConfigUnitAmount, + MatrixWithDisplayNameConfigUnitAmountFromRaw >) )] public sealed record class MatrixWithDisplayNameConfigUnitAmount : JsonModel @@ -555,7 +550,7 @@ public override void Validate() public MatrixWithDisplayNameConfigUnitAmount() { } public MatrixWithDisplayNameConfigUnitAmount( - global::Orb.Models.Subscriptions.MatrixWithDisplayNameConfigUnitAmount matrixWithDisplayNameConfigUnitAmount + MatrixWithDisplayNameConfigUnitAmount matrixWithDisplayNameConfigUnitAmount ) : base(matrixWithDisplayNameConfigUnitAmount) { } @@ -572,8 +567,8 @@ public MatrixWithDisplayNameConfigUnitAmount(IReadOnlyDictionary - public static global::Orb.Models.Subscriptions.MatrixWithDisplayNameConfigUnitAmount FromRawUnchecked( + /// + public static MatrixWithDisplayNameConfigUnitAmount FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -582,15 +577,12 @@ IReadOnlyDictionary rawData } class MatrixWithDisplayNameConfigUnitAmountFromRaw - : IFromRawJson + : IFromRawJson { /// - public global::Orb.Models.Subscriptions.MatrixWithDisplayNameConfigUnitAmount FromRawUnchecked( + public MatrixWithDisplayNameConfigUnitAmount FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Subscriptions.MatrixWithDisplayNameConfigUnitAmount.FromRawUnchecked( - rawData - ); + ) => MatrixWithDisplayNameConfigUnitAmount.FromRawUnchecked(rawData); } /// diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePrice.cs index c9ee665e..5ddb44a8 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePrice.cs @@ -49,12 +49,12 @@ public required string ItemID /// /// Configuration for max_group_tiered_package pricing /// - public required global::Orb.Models.Subscriptions.MaxGroupTieredPackageConfig MaxGroupTieredPackageConfig + public required MaxGroupTieredPackageConfig MaxGroupTieredPackageConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "max_group_tiered_package_config" ); } @@ -406,10 +406,7 @@ JsonSerializerOptions options /// Configuration for max_group_tiered_package pricing /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.MaxGroupTieredPackageConfig, - global::Orb.Models.Subscriptions.MaxGroupTieredPackageConfigFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class MaxGroupTieredPackageConfig : JsonModel { @@ -439,20 +436,21 @@ public required string PackageSize /// /// Apply tiered pricing to the largest group after grouping with the provided key. /// - public required IReadOnlyList Tiers + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + return this._rawData.GetNotNullStruct>( + "tiers" + ); } init { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); } } @@ -469,9 +467,7 @@ public override void Validate() public MaxGroupTieredPackageConfig() { } - public MaxGroupTieredPackageConfig( - global::Orb.Models.Subscriptions.MaxGroupTieredPackageConfig maxGroupTieredPackageConfig - ) + public MaxGroupTieredPackageConfig(MaxGroupTieredPackageConfig maxGroupTieredPackageConfig) : base(maxGroupTieredPackageConfig) { } public MaxGroupTieredPackageConfig(IReadOnlyDictionary rawData) @@ -487,8 +483,8 @@ public MaxGroupTieredPackageConfig(IReadOnlyDictionary rawD } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.MaxGroupTieredPackageConfig FromRawUnchecked( + /// + public static MaxGroupTieredPackageConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -496,13 +492,12 @@ IReadOnlyDictionary rawData } } -class MaxGroupTieredPackageConfigFromRaw - : IFromRawJson +class MaxGroupTieredPackageConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.MaxGroupTieredPackageConfig FromRawUnchecked( + public MaxGroupTieredPackageConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.MaxGroupTieredPackageConfig.FromRawUnchecked(rawData); + ) => MaxGroupTieredPackageConfig.FromRawUnchecked(rawData); } /// @@ -510,8 +505,8 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.MaxGroupTieredPackageConfigTier, - global::Orb.Models.Subscriptions.MaxGroupTieredPackageConfigTierFromRaw + MaxGroupTieredPackageConfigTier, + MaxGroupTieredPackageConfigTierFromRaw >) )] public sealed record class MaxGroupTieredPackageConfigTier : JsonModel @@ -549,7 +544,7 @@ public override void Validate() public MaxGroupTieredPackageConfigTier() { } public MaxGroupTieredPackageConfigTier( - global::Orb.Models.Subscriptions.MaxGroupTieredPackageConfigTier maxGroupTieredPackageConfigTier + MaxGroupTieredPackageConfigTier maxGroupTieredPackageConfigTier ) : base(maxGroupTieredPackageConfigTier) { } @@ -566,8 +561,8 @@ public MaxGroupTieredPackageConfigTier(IReadOnlyDictionary } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.MaxGroupTieredPackageConfigTier FromRawUnchecked( + /// + public static MaxGroupTieredPackageConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -575,13 +570,12 @@ IReadOnlyDictionary rawData } } -class MaxGroupTieredPackageConfigTierFromRaw - : IFromRawJson +class MaxGroupTieredPackageConfigTierFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.MaxGroupTieredPackageConfigTier FromRawUnchecked( + public MaxGroupTieredPackageConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.MaxGroupTieredPackageConfigTier.FromRawUnchecked(rawData); + ) => MaxGroupTieredPackageConfigTier.FromRawUnchecked(rawData); } /// diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMinimumCompositePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMinimumCompositePrice.cs index 7b742fca..2fbc8b53 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionMinimumCompositePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionMinimumCompositePrice.cs @@ -48,12 +48,12 @@ public required string ItemID /// /// Configuration for minimum_composite pricing /// - public required global::Orb.Models.Subscriptions.MinimumCompositeConfig MinimumCompositeConfig + public required MinimumCompositeConfig MinimumCompositeConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "minimum_composite_config" ); } @@ -402,12 +402,7 @@ JsonSerializerOptions options /// /// Configuration for minimum_composite pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.MinimumCompositeConfig, - global::Orb.Models.Subscriptions.MinimumCompositeConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class MinimumCompositeConfig : JsonModel { /// @@ -453,9 +448,7 @@ public override void Validate() public MinimumCompositeConfig() { } - public MinimumCompositeConfig( - global::Orb.Models.Subscriptions.MinimumCompositeConfig minimumCompositeConfig - ) + public MinimumCompositeConfig(MinimumCompositeConfig minimumCompositeConfig) : base(minimumCompositeConfig) { } public MinimumCompositeConfig(IReadOnlyDictionary rawData) @@ -471,8 +464,8 @@ public MinimumCompositeConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.MinimumCompositeConfig FromRawUnchecked( + /// + public static MinimumCompositeConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -487,13 +480,12 @@ public MinimumCompositeConfig(string minimumAmount) } } -class MinimumCompositeConfigFromRaw - : IFromRawJson +class MinimumCompositeConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.MinimumCompositeConfig FromRawUnchecked( + public MinimumCompositeConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.MinimumCompositeConfig.FromRawUnchecked(rawData); + ) => MinimumCompositeConfig.FromRawUnchecked(rawData); } /// diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionPackageWithAllocationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionPackageWithAllocationPrice.cs index f82c1228..a241b611 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionPackageWithAllocationPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionPackageWithAllocationPrice.cs @@ -76,12 +76,12 @@ public required string Name /// /// Configuration for package_with_allocation pricing /// - public required global::Orb.Models.Subscriptions.PackageWithAllocationConfig PackageWithAllocationConfig + public required PackageWithAllocationConfig PackageWithAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "package_with_allocation_config" ); } @@ -452,10 +452,7 @@ JsonSerializerOptions options /// Configuration for package_with_allocation pricing /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.PackageWithAllocationConfig, - global::Orb.Models.Subscriptions.PackageWithAllocationConfigFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class PackageWithAllocationConfig : JsonModel { @@ -499,9 +496,7 @@ public override void Validate() public PackageWithAllocationConfig() { } - public PackageWithAllocationConfig( - global::Orb.Models.Subscriptions.PackageWithAllocationConfig packageWithAllocationConfig - ) + public PackageWithAllocationConfig(PackageWithAllocationConfig packageWithAllocationConfig) : base(packageWithAllocationConfig) { } public PackageWithAllocationConfig(IReadOnlyDictionary rawData) @@ -517,8 +512,8 @@ public PackageWithAllocationConfig(IReadOnlyDictionary rawD } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.PackageWithAllocationConfig FromRawUnchecked( + /// + public static PackageWithAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -526,13 +521,12 @@ IReadOnlyDictionary rawData } } -class PackageWithAllocationConfigFromRaw - : IFromRawJson +class PackageWithAllocationConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.PackageWithAllocationConfig FromRawUnchecked( + public PackageWithAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.PackageWithAllocationConfig.FromRawUnchecked(rawData); + ) => PackageWithAllocationConfig.FromRawUnchecked(rawData); } [JsonConverter(typeof(NewSubscriptionPackageWithAllocationPriceConversionRateConfigConverter))] diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPrice.cs index 7e390a37..304d377e 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPrice.cs @@ -83,12 +83,12 @@ public required string Name /// /// Configuration for scalable_matrix_with_tiered_pricing pricing /// - public required global::Orb.Models.Subscriptions.ScalableMatrixWithTieredPricingConfig ScalableMatrixWithTieredPricingConfig + public required ScalableMatrixWithTieredPricingConfig ScalableMatrixWithTieredPricingConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "scalable_matrix_with_tiered_pricing_config" ); } @@ -463,8 +463,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.ScalableMatrixWithTieredPricingConfig, - global::Orb.Models.Subscriptions.ScalableMatrixWithTieredPricingConfigFromRaw + ScalableMatrixWithTieredPricingConfig, + ScalableMatrixWithTieredPricingConfigFromRaw >) )] public sealed record class ScalableMatrixWithTieredPricingConfig : JsonModel @@ -485,38 +485,39 @@ public required string FirstDimension /// /// Apply a scaling factor to each dimension /// - public required IReadOnlyList MatrixScalingFactors + public required IReadOnlyList MatrixScalingFactors { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("matrix_scaling_factors"); + return this._rawData.GetNotNullStruct>( + "matrix_scaling_factors" + ); } init { - this._rawData.Set>( + this._rawData.Set>( "matrix_scaling_factors", ImmutableArray.ToImmutableArray(value) ); } } - public required IReadOnlyList Tiers + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); return this._rawData.GetNotNullStruct< - ImmutableArray + ImmutableArray >("tiers"); } init { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); } } @@ -551,7 +552,7 @@ public override void Validate() public ScalableMatrixWithTieredPricingConfig() { } public ScalableMatrixWithTieredPricingConfig( - global::Orb.Models.Subscriptions.ScalableMatrixWithTieredPricingConfig scalableMatrixWithTieredPricingConfig + ScalableMatrixWithTieredPricingConfig scalableMatrixWithTieredPricingConfig ) : base(scalableMatrixWithTieredPricingConfig) { } @@ -568,8 +569,8 @@ public ScalableMatrixWithTieredPricingConfig(IReadOnlyDictionary - public static global::Orb.Models.Subscriptions.ScalableMatrixWithTieredPricingConfig FromRawUnchecked( + /// + public static ScalableMatrixWithTieredPricingConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -578,26 +579,18 @@ IReadOnlyDictionary rawData } class ScalableMatrixWithTieredPricingConfigFromRaw - : IFromRawJson + : IFromRawJson { /// - public global::Orb.Models.Subscriptions.ScalableMatrixWithTieredPricingConfig FromRawUnchecked( + public ScalableMatrixWithTieredPricingConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Subscriptions.ScalableMatrixWithTieredPricingConfig.FromRawUnchecked( - rawData - ); + ) => ScalableMatrixWithTieredPricingConfig.FromRawUnchecked(rawData); } /// /// Configuration for a single matrix scaling factor /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.MatrixScalingFactor, - global::Orb.Models.Subscriptions.MatrixScalingFactorFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class MatrixScalingFactor : JsonModel { public required string FirstDimensionValue @@ -640,9 +633,7 @@ public override void Validate() public MatrixScalingFactor() { } - public MatrixScalingFactor( - global::Orb.Models.Subscriptions.MatrixScalingFactor matrixScalingFactor - ) + public MatrixScalingFactor(MatrixScalingFactor matrixScalingFactor) : base(matrixScalingFactor) { } public MatrixScalingFactor(IReadOnlyDictionary rawData) @@ -658,8 +649,8 @@ public MatrixScalingFactor(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.MatrixScalingFactor FromRawUnchecked( + /// + public static MatrixScalingFactor FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -667,13 +658,11 @@ IReadOnlyDictionary rawData } } -class MatrixScalingFactorFromRaw - : IFromRawJson +class MatrixScalingFactorFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.MatrixScalingFactor FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.MatrixScalingFactor.FromRawUnchecked(rawData); + public MatrixScalingFactor FromRawUnchecked(IReadOnlyDictionary rawData) => + MatrixScalingFactor.FromRawUnchecked(rawData); } /// @@ -681,8 +670,8 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.ScalableMatrixWithTieredPricingConfigTier, - global::Orb.Models.Subscriptions.ScalableMatrixWithTieredPricingConfigTierFromRaw + ScalableMatrixWithTieredPricingConfigTier, + ScalableMatrixWithTieredPricingConfigTierFromRaw >) )] public sealed record class ScalableMatrixWithTieredPricingConfigTier : JsonModel @@ -717,7 +706,7 @@ public override void Validate() public ScalableMatrixWithTieredPricingConfigTier() { } public ScalableMatrixWithTieredPricingConfigTier( - global::Orb.Models.Subscriptions.ScalableMatrixWithTieredPricingConfigTier scalableMatrixWithTieredPricingConfigTier + ScalableMatrixWithTieredPricingConfigTier scalableMatrixWithTieredPricingConfigTier ) : base(scalableMatrixWithTieredPricingConfigTier) { } @@ -736,8 +725,8 @@ IReadOnlyDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.ScalableMatrixWithTieredPricingConfigTier FromRawUnchecked( + /// + public static ScalableMatrixWithTieredPricingConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -746,15 +735,12 @@ IReadOnlyDictionary rawData } class ScalableMatrixWithTieredPricingConfigTierFromRaw - : IFromRawJson + : IFromRawJson { /// - public global::Orb.Models.Subscriptions.ScalableMatrixWithTieredPricingConfigTier FromRawUnchecked( + public ScalableMatrixWithTieredPricingConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Subscriptions.ScalableMatrixWithTieredPricingConfigTier.FromRawUnchecked( - rawData - ); + ) => ScalableMatrixWithTieredPricingConfigTier.FromRawUnchecked(rawData); } [JsonConverter( diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs index 369b5f6f..d93a3cf8 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs @@ -83,12 +83,12 @@ public required string Name /// /// Configuration for scalable_matrix_with_unit_pricing pricing /// - public required global::Orb.Models.Subscriptions.ScalableMatrixWithUnitPricingConfig ScalableMatrixWithUnitPricingConfig + public required ScalableMatrixWithUnitPricingConfig ScalableMatrixWithUnitPricingConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "scalable_matrix_with_unit_pricing_config" ); } @@ -461,8 +461,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.ScalableMatrixWithUnitPricingConfig, - global::Orb.Models.Subscriptions.ScalableMatrixWithUnitPricingConfigFromRaw + ScalableMatrixWithUnitPricingConfig, + ScalableMatrixWithUnitPricingConfigFromRaw >) )] public sealed record class ScalableMatrixWithUnitPricingConfig : JsonModel @@ -483,19 +483,19 @@ public required string FirstDimension /// /// Apply a scaling factor to each dimension /// - public required IReadOnlyList MatrixScalingFactors + public required IReadOnlyList MatrixScalingFactors { get { this._rawData.Freeze(); return this._rawData.GetNotNullStruct< - ImmutableArray + ImmutableArray >("matrix_scaling_factors"); } init { this._rawData.Set< - ImmutableArray + ImmutableArray >("matrix_scaling_factors", ImmutableArray.ToImmutableArray(value)); } } @@ -555,7 +555,7 @@ public override void Validate() public ScalableMatrixWithUnitPricingConfig() { } public ScalableMatrixWithUnitPricingConfig( - global::Orb.Models.Subscriptions.ScalableMatrixWithUnitPricingConfig scalableMatrixWithUnitPricingConfig + ScalableMatrixWithUnitPricingConfig scalableMatrixWithUnitPricingConfig ) : base(scalableMatrixWithUnitPricingConfig) { } @@ -572,8 +572,8 @@ public ScalableMatrixWithUnitPricingConfig(IReadOnlyDictionary - public static global::Orb.Models.Subscriptions.ScalableMatrixWithUnitPricingConfig FromRawUnchecked( + /// + public static ScalableMatrixWithUnitPricingConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -581,16 +581,12 @@ IReadOnlyDictionary rawData } } -class ScalableMatrixWithUnitPricingConfigFromRaw - : IFromRawJson +class ScalableMatrixWithUnitPricingConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.ScalableMatrixWithUnitPricingConfig FromRawUnchecked( + public ScalableMatrixWithUnitPricingConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Subscriptions.ScalableMatrixWithUnitPricingConfig.FromRawUnchecked( - rawData - ); + ) => ScalableMatrixWithUnitPricingConfig.FromRawUnchecked(rawData); } /// @@ -598,8 +594,8 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.ScalableMatrixWithUnitPricingConfigMatrixScalingFactor, - global::Orb.Models.Subscriptions.ScalableMatrixWithUnitPricingConfigMatrixScalingFactorFromRaw + ScalableMatrixWithUnitPricingConfigMatrixScalingFactor, + ScalableMatrixWithUnitPricingConfigMatrixScalingFactorFromRaw >) )] public sealed record class ScalableMatrixWithUnitPricingConfigMatrixScalingFactor : JsonModel @@ -645,7 +641,7 @@ public override void Validate() public ScalableMatrixWithUnitPricingConfigMatrixScalingFactor() { } public ScalableMatrixWithUnitPricingConfigMatrixScalingFactor( - global::Orb.Models.Subscriptions.ScalableMatrixWithUnitPricingConfigMatrixScalingFactor scalableMatrixWithUnitPricingConfigMatrixScalingFactor + ScalableMatrixWithUnitPricingConfigMatrixScalingFactor scalableMatrixWithUnitPricingConfigMatrixScalingFactor ) : base(scalableMatrixWithUnitPricingConfigMatrixScalingFactor) { } @@ -666,8 +662,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.ScalableMatrixWithUnitPricingConfigMatrixScalingFactor FromRawUnchecked( + /// + public static ScalableMatrixWithUnitPricingConfigMatrixScalingFactor FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -676,15 +672,12 @@ IReadOnlyDictionary rawData } class ScalableMatrixWithUnitPricingConfigMatrixScalingFactorFromRaw - : IFromRawJson + : IFromRawJson { /// - public global::Orb.Models.Subscriptions.ScalableMatrixWithUnitPricingConfigMatrixScalingFactor FromRawUnchecked( + public ScalableMatrixWithUnitPricingConfigMatrixScalingFactor FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Subscriptions.ScalableMatrixWithUnitPricingConfigMatrixScalingFactor.FromRawUnchecked( - rawData - ); + ) => ScalableMatrixWithUnitPricingConfigMatrixScalingFactor.FromRawUnchecked(rawData); } [JsonConverter( diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPrice.cs index 8b368dc9..b20a1d51 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPrice.cs @@ -77,12 +77,12 @@ public required string Name /// /// Configuration for threshold_total_amount pricing /// - public required global::Orb.Models.Subscriptions.ThresholdTotalAmountConfig ThresholdTotalAmountConfig + public required ThresholdTotalAmountConfig ThresholdTotalAmountConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "threshold_total_amount_config" ); } @@ -453,10 +453,7 @@ JsonSerializerOptions options /// Configuration for threshold_total_amount pricing /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.ThresholdTotalAmountConfig, - global::Orb.Models.Subscriptions.ThresholdTotalAmountConfigFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class ThresholdTotalAmountConfig : JsonModel { @@ -464,18 +461,18 @@ public sealed record class ThresholdTotalAmountConfig : JsonModel /// When the quantity consumed passes a provided threshold, the configured total /// will be charged /// - public required IReadOnlyList ConsumptionTable + public required IReadOnlyList ConsumptionTable { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("consumption_table"); + return this._rawData.GetNotNullStruct>( + "consumption_table" + ); } init { - this._rawData.Set>( + this._rawData.Set>( "consumption_table", ImmutableArray.ToImmutableArray(value) ); @@ -507,9 +504,7 @@ public override void Validate() public ThresholdTotalAmountConfig() { } - public ThresholdTotalAmountConfig( - global::Orb.Models.Subscriptions.ThresholdTotalAmountConfig thresholdTotalAmountConfig - ) + public ThresholdTotalAmountConfig(ThresholdTotalAmountConfig thresholdTotalAmountConfig) : base(thresholdTotalAmountConfig) { } public ThresholdTotalAmountConfig(IReadOnlyDictionary rawData) @@ -525,8 +520,8 @@ public ThresholdTotalAmountConfig(IReadOnlyDictionary rawDa } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.ThresholdTotalAmountConfig FromRawUnchecked( + /// + public static ThresholdTotalAmountConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -534,33 +529,25 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public ThresholdTotalAmountConfig( - IReadOnlyList consumptionTable - ) + public ThresholdTotalAmountConfig(IReadOnlyList consumptionTable) : this() { this.ConsumptionTable = consumptionTable; } } -class ThresholdTotalAmountConfigFromRaw - : IFromRawJson +class ThresholdTotalAmountConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.ThresholdTotalAmountConfig FromRawUnchecked( + public ThresholdTotalAmountConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.ThresholdTotalAmountConfig.FromRawUnchecked(rawData); + ) => ThresholdTotalAmountConfig.FromRawUnchecked(rawData); } /// /// Configuration for a single threshold /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.ConsumptionTable, - global::Orb.Models.Subscriptions.ConsumptionTableFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class ConsumptionTable : JsonModel { public required string Threshold @@ -595,7 +582,7 @@ public override void Validate() public ConsumptionTable() { } - public ConsumptionTable(global::Orb.Models.Subscriptions.ConsumptionTable consumptionTable) + public ConsumptionTable(ConsumptionTable consumptionTable) : base(consumptionTable) { } public ConsumptionTable(IReadOnlyDictionary rawData) @@ -611,8 +598,8 @@ public ConsumptionTable(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.ConsumptionTable FromRawUnchecked( + /// + public static ConsumptionTable FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -620,12 +607,11 @@ IReadOnlyDictionary rawData } } -class ConsumptionTableFromRaw : IFromRawJson +class ConsumptionTableFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.ConsumptionTable FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.ConsumptionTable.FromRawUnchecked(rawData); + public ConsumptionTable FromRawUnchecked(IReadOnlyDictionary rawData) => + ConsumptionTable.FromRawUnchecked(rawData); } [JsonConverter(typeof(NewSubscriptionThresholdTotalAmountPriceConversionRateConfigConverter))] diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackagePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackagePrice.cs index b343c95c..3e3342e2 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackagePrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackagePrice.cs @@ -77,14 +77,12 @@ public required string Name /// /// Configuration for tiered_package pricing /// - public required global::Orb.Models.Subscriptions.TieredPackageConfig TieredPackageConfig + public required TieredPackageConfig TieredPackageConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "tiered_package_config" - ); + return this._rawData.GetNotNullClass("tiered_package_config"); } init { this._rawData.Set("tiered_package_config", value); } } @@ -447,12 +445,7 @@ JsonSerializerOptions options /// /// Configuration for tiered_package pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.TieredPackageConfig, - global::Orb.Models.Subscriptions.TieredPackageConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class TieredPackageConfig : JsonModel { public required string PackageSize @@ -471,20 +464,19 @@ public required string PackageSize /// based on the total quantity rather than the number of packages, so they must /// be multiples of the package size. /// - public required IReadOnlyList Tiers + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + return this._rawData.GetNotNullStruct>("tiers"); } init { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); } } @@ -500,9 +492,7 @@ public override void Validate() public TieredPackageConfig() { } - public TieredPackageConfig( - global::Orb.Models.Subscriptions.TieredPackageConfig tieredPackageConfig - ) + public TieredPackageConfig(TieredPackageConfig tieredPackageConfig) : base(tieredPackageConfig) { } public TieredPackageConfig(IReadOnlyDictionary rawData) @@ -518,8 +508,8 @@ public TieredPackageConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.TieredPackageConfig FromRawUnchecked( + /// + public static TieredPackageConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -527,24 +517,17 @@ IReadOnlyDictionary rawData } } -class TieredPackageConfigFromRaw - : IFromRawJson +class TieredPackageConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.TieredPackageConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.TieredPackageConfig.FromRawUnchecked(rawData); + public TieredPackageConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredPackageConfig.FromRawUnchecked(rawData); } /// /// Configuration for a single tier with business logic /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.TieredPackageConfigTier, - global::Orb.Models.Subscriptions.TieredPackageConfigTierFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class TieredPackageConfigTier : JsonModel { /// @@ -579,9 +562,7 @@ public override void Validate() public TieredPackageConfigTier() { } - public TieredPackageConfigTier( - global::Orb.Models.Subscriptions.TieredPackageConfigTier tieredPackageConfigTier - ) + public TieredPackageConfigTier(TieredPackageConfigTier tieredPackageConfigTier) : base(tieredPackageConfigTier) { } public TieredPackageConfigTier(IReadOnlyDictionary rawData) @@ -597,8 +578,8 @@ public TieredPackageConfigTier(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.TieredPackageConfigTier FromRawUnchecked( + /// + public static TieredPackageConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -606,13 +587,12 @@ IReadOnlyDictionary rawData } } -class TieredPackageConfigTierFromRaw - : IFromRawJson +class TieredPackageConfigTierFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.TieredPackageConfigTier FromRawUnchecked( + public TieredPackageConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.TieredPackageConfigTier.FromRawUnchecked(rawData); + ) => TieredPackageConfigTier.FromRawUnchecked(rawData); } [JsonConverter(typeof(NewSubscriptionTieredPackagePriceConversionRateConfigConverter))] diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPrice.cs index b279882c..6d31b48f 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPrice.cs @@ -77,12 +77,12 @@ public required string Name /// /// Configuration for tiered_package_with_minimum pricing /// - public required global::Orb.Models.Subscriptions.TieredPackageWithMinimumConfig TieredPackageWithMinimumConfig + public required TieredPackageWithMinimumConfig TieredPackageWithMinimumConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "tiered_package_with_minimum_config" ); } @@ -454,8 +454,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.TieredPackageWithMinimumConfig, - global::Orb.Models.Subscriptions.TieredPackageWithMinimumConfigFromRaw + TieredPackageWithMinimumConfig, + TieredPackageWithMinimumConfigFromRaw >) )] public sealed record class TieredPackageWithMinimumConfig : JsonModel @@ -474,20 +474,21 @@ public required double PackageSize /// Apply tiered pricing after rounding up the quantity to the package size. /// Tiers are defined using exclusive lower bounds. /// - public required IReadOnlyList Tiers + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); return this._rawData.GetNotNullStruct< - ImmutableArray + ImmutableArray >("tiers"); } init { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); } } @@ -504,7 +505,7 @@ public override void Validate() public TieredPackageWithMinimumConfig() { } public TieredPackageWithMinimumConfig( - global::Orb.Models.Subscriptions.TieredPackageWithMinimumConfig tieredPackageWithMinimumConfig + TieredPackageWithMinimumConfig tieredPackageWithMinimumConfig ) : base(tieredPackageWithMinimumConfig) { } @@ -521,8 +522,8 @@ public TieredPackageWithMinimumConfig(IReadOnlyDictionary r } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.TieredPackageWithMinimumConfig FromRawUnchecked( + /// + public static TieredPackageWithMinimumConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -530,13 +531,12 @@ IReadOnlyDictionary rawData } } -class TieredPackageWithMinimumConfigFromRaw - : IFromRawJson +class TieredPackageWithMinimumConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.TieredPackageWithMinimumConfig FromRawUnchecked( + public TieredPackageWithMinimumConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.TieredPackageWithMinimumConfig.FromRawUnchecked(rawData); + ) => TieredPackageWithMinimumConfig.FromRawUnchecked(rawData); } /// @@ -544,8 +544,8 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.TieredPackageWithMinimumConfigTier, - global::Orb.Models.Subscriptions.TieredPackageWithMinimumConfigTierFromRaw + TieredPackageWithMinimumConfigTier, + TieredPackageWithMinimumConfigTierFromRaw >) )] public sealed record class TieredPackageWithMinimumConfigTier : JsonModel @@ -591,7 +591,7 @@ public override void Validate() public TieredPackageWithMinimumConfigTier() { } public TieredPackageWithMinimumConfigTier( - global::Orb.Models.Subscriptions.TieredPackageWithMinimumConfigTier tieredPackageWithMinimumConfigTier + TieredPackageWithMinimumConfigTier tieredPackageWithMinimumConfigTier ) : base(tieredPackageWithMinimumConfigTier) { } @@ -608,8 +608,8 @@ public TieredPackageWithMinimumConfigTier(IReadOnlyDictionary - public static global::Orb.Models.Subscriptions.TieredPackageWithMinimumConfigTier FromRawUnchecked( + /// + public static TieredPackageWithMinimumConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -617,16 +617,12 @@ IReadOnlyDictionary rawData } } -class TieredPackageWithMinimumConfigTierFromRaw - : IFromRawJson +class TieredPackageWithMinimumConfigTierFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.TieredPackageWithMinimumConfigTier FromRawUnchecked( + public TieredPackageWithMinimumConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Subscriptions.TieredPackageWithMinimumConfigTier.FromRawUnchecked( - rawData - ); + ) => TieredPackageWithMinimumConfigTier.FromRawUnchecked(rawData); } [JsonConverter(typeof(NewSubscriptionTieredPackageWithMinimumPriceConversionRateConfigConverter))] diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionTieredWithMinimumPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionTieredWithMinimumPrice.cs index 9cfb8200..cef8a961 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionTieredWithMinimumPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionTieredWithMinimumPrice.cs @@ -77,12 +77,12 @@ public required string Name /// /// Configuration for tiered_with_minimum pricing /// - public required global::Orb.Models.Subscriptions.TieredWithMinimumConfig TieredWithMinimumConfig + public required TieredWithMinimumConfig TieredWithMinimumConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "tiered_with_minimum_config" ); } @@ -450,32 +450,28 @@ JsonSerializerOptions options /// /// Configuration for tiered_with_minimum pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.TieredWithMinimumConfig, - global::Orb.Models.Subscriptions.TieredWithMinimumConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class TieredWithMinimumConfig : JsonModel { /// /// Tiered pricing with a minimum amount dependent on the volume tier. Tiers /// are defined using exclusive lower bounds. /// - public required IReadOnlyList Tiers + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + return this._rawData.GetNotNullStruct>( + "tiers" + ); } init { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); } } @@ -534,9 +530,7 @@ public override void Validate() public TieredWithMinimumConfig() { } - public TieredWithMinimumConfig( - global::Orb.Models.Subscriptions.TieredWithMinimumConfig tieredWithMinimumConfig - ) + public TieredWithMinimumConfig(TieredWithMinimumConfig tieredWithMinimumConfig) : base(tieredWithMinimumConfig) { } public TieredWithMinimumConfig(IReadOnlyDictionary rawData) @@ -552,8 +546,8 @@ public TieredWithMinimumConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.TieredWithMinimumConfig FromRawUnchecked( + /// + public static TieredWithMinimumConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -561,32 +555,26 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public TieredWithMinimumConfig( - IReadOnlyList tiers - ) + public TieredWithMinimumConfig(IReadOnlyList tiers) : this() { this.Tiers = tiers; } } -class TieredWithMinimumConfigFromRaw - : IFromRawJson +class TieredWithMinimumConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.TieredWithMinimumConfig FromRawUnchecked( + public TieredWithMinimumConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.TieredWithMinimumConfig.FromRawUnchecked(rawData); + ) => TieredWithMinimumConfig.FromRawUnchecked(rawData); } /// /// Configuration for a single tier /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.TieredWithMinimumConfigTier, - global::Orb.Models.Subscriptions.TieredWithMinimumConfigTierFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class TieredWithMinimumConfigTier : JsonModel { @@ -633,9 +621,7 @@ public override void Validate() public TieredWithMinimumConfigTier() { } - public TieredWithMinimumConfigTier( - global::Orb.Models.Subscriptions.TieredWithMinimumConfigTier tieredWithMinimumConfigTier - ) + public TieredWithMinimumConfigTier(TieredWithMinimumConfigTier tieredWithMinimumConfigTier) : base(tieredWithMinimumConfigTier) { } public TieredWithMinimumConfigTier(IReadOnlyDictionary rawData) @@ -651,8 +637,8 @@ public TieredWithMinimumConfigTier(IReadOnlyDictionary rawD } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.TieredWithMinimumConfigTier FromRawUnchecked( + /// + public static TieredWithMinimumConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -660,13 +646,12 @@ IReadOnlyDictionary rawData } } -class TieredWithMinimumConfigTierFromRaw - : IFromRawJson +class TieredWithMinimumConfigTierFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.TieredWithMinimumConfigTier FromRawUnchecked( + public TieredWithMinimumConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.TieredWithMinimumConfigTier.FromRawUnchecked(rawData); + ) => TieredWithMinimumConfigTier.FromRawUnchecked(rawData); } [JsonConverter(typeof(NewSubscriptionTieredWithMinimumPriceConversionRateConfigConverter))] diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithPercentPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithPercentPrice.cs index 76992d4a..ba93e752 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithPercentPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithPercentPrice.cs @@ -76,14 +76,12 @@ public required string Name /// /// Configuration for unit_with_percent pricing /// - public required global::Orb.Models.Subscriptions.UnitWithPercentConfig UnitWithPercentConfig + public required UnitWithPercentConfig UnitWithPercentConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "unit_with_percent_config" - ); + return this._rawData.GetNotNullClass("unit_with_percent_config"); } init { this._rawData.Set("unit_with_percent_config", value); } } @@ -446,12 +444,7 @@ JsonSerializerOptions options /// /// Configuration for unit_with_percent pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.UnitWithPercentConfig, - global::Orb.Models.Subscriptions.UnitWithPercentConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class UnitWithPercentConfig : JsonModel { /// @@ -489,9 +482,7 @@ public override void Validate() public UnitWithPercentConfig() { } - public UnitWithPercentConfig( - global::Orb.Models.Subscriptions.UnitWithPercentConfig unitWithPercentConfig - ) + public UnitWithPercentConfig(UnitWithPercentConfig unitWithPercentConfig) : base(unitWithPercentConfig) { } public UnitWithPercentConfig(IReadOnlyDictionary rawData) @@ -507,8 +498,8 @@ public UnitWithPercentConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.UnitWithPercentConfig FromRawUnchecked( + /// + public static UnitWithPercentConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -516,13 +507,12 @@ IReadOnlyDictionary rawData } } -class UnitWithPercentConfigFromRaw - : IFromRawJson +class UnitWithPercentConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.UnitWithPercentConfig FromRawUnchecked( + public UnitWithPercentConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.UnitWithPercentConfig.FromRawUnchecked(rawData); + ) => UnitWithPercentConfig.FromRawUnchecked(rawData); } [JsonConverter(typeof(NewSubscriptionUnitWithPercentPriceConversionRateConfigConverter))] diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithProrationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithProrationPrice.cs index 2a11c3c4..33d03f2e 100644 --- a/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithProrationPrice.cs +++ b/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithProrationPrice.cs @@ -76,12 +76,12 @@ public required string Name /// /// Configuration for unit_with_proration pricing /// - public required global::Orb.Models.Subscriptions.UnitWithProrationConfig UnitWithProrationConfig + public required UnitWithProrationConfig UnitWithProrationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "unit_with_proration_config" ); } @@ -449,12 +449,7 @@ JsonSerializerOptions options /// /// Configuration for unit_with_proration pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.UnitWithProrationConfig, - global::Orb.Models.Subscriptions.UnitWithProrationConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class UnitWithProrationConfig : JsonModel { /// @@ -478,9 +473,7 @@ public override void Validate() public UnitWithProrationConfig() { } - public UnitWithProrationConfig( - global::Orb.Models.Subscriptions.UnitWithProrationConfig unitWithProrationConfig - ) + public UnitWithProrationConfig(UnitWithProrationConfig unitWithProrationConfig) : base(unitWithProrationConfig) { } public UnitWithProrationConfig(IReadOnlyDictionary rawData) @@ -496,8 +489,8 @@ public UnitWithProrationConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.UnitWithProrationConfig FromRawUnchecked( + /// + public static UnitWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -512,13 +505,12 @@ public UnitWithProrationConfig(string unitAmount) } } -class UnitWithProrationConfigFromRaw - : IFromRawJson +class UnitWithProrationConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.UnitWithProrationConfig FromRawUnchecked( + public UnitWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.UnitWithProrationConfig.FromRawUnchecked(rawData); + ) => UnitWithProrationConfig.FromRawUnchecked(rawData); } [JsonConverter(typeof(NewSubscriptionUnitWithProrationPriceConversionRateConfigConverter))] diff --git a/src/Orb/Models/Subscriptions/SubscriptionCancelParams.cs b/src/Orb/Models/Subscriptions/SubscriptionCancelParams.cs index 7308e5a0..080675a6 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionCancelParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionCancelParams.cs @@ -62,8 +62,12 @@ namespace Orb.Models.Subscriptions; /// generate a balance refund for the current period. If the cancellation is before /// the most recently issued invoice, Orb will void the intervening invoice and generate /// a new one based on the new dates for the subscription. See the section on [cancellation behaviors](/product-catalog/creating-subscriptions#cancellation-behaviors). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionCancelParams : ParamsBase +public record class SubscriptionCancelParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -119,6 +123,8 @@ public bool? AllowInvoiceCreditOrVoid public SubscriptionCancelParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionCancelParams(SubscriptionCancelParams subscriptionCancelParams) : base(subscriptionCancelParams) { @@ -126,6 +132,7 @@ public SubscriptionCancelParams(SubscriptionCancelParams subscriptionCancelParam this._rawBodyData = new(subscriptionCancelParams._rawBodyData); } +#pragma warning restore CS8618 public SubscriptionCancelParams( IReadOnlyDictionary rawHeaderData, @@ -166,6 +173,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["SubscriptionID"] = this.SubscriptionID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionCancelParams? other) + { + if (other == null) + { + return false; + } + return (this.SubscriptionID?.Equals(other.SubscriptionID) ?? other.SubscriptionID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -194,6 +225,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// diff --git a/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs b/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs index 8313b800..96de90d5 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs @@ -206,8 +206,12 @@ namespace Orb.Models.Subscriptions; /// /// ## Limits By default, Orb limits the number of subscriptions per customer /// to 100. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionCreateParams : ParamsBase +public record class SubscriptionCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -734,11 +738,14 @@ public IReadOnlyList? UsageCustomerIds public SubscriptionCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionCreateParams(SubscriptionCreateParams subscriptionCreateParams) : base(subscriptionCreateParams) { this._rawBodyData = new(subscriptionCreateParams._rawBodyData); } +#pragma warning restore CS8618 public SubscriptionCreateParams( IReadOnlyDictionary rawHeaderData, @@ -779,6 +786,28 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/subscriptions") @@ -804,6 +833,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(JsonModelConverter))] @@ -812,14 +846,12 @@ public sealed record class AddAdjustment : JsonModel /// /// The definition of a new adjustment to create and add to the subscription. /// - public required global::Orb.Models.Subscriptions.Adjustment Adjustment + public required Adjustment Adjustment { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "adjustment" - ); + return this._rawData.GetNotNullClass("adjustment"); } init { this._rawData.Set("adjustment", value); } } @@ -900,7 +932,7 @@ public static AddAdjustment FromRawUnchecked(IReadOnlyDictionary r /// /// The definition of a new adjustment to create and add to the subscription. /// -[JsonConverter(typeof(global::Orb.Models.Subscriptions.AdjustmentConverter))] +[JsonConverter(typeof(AdjustmentConverter))] public record class Adjustment : ModelBase { public object? Value { get; } = null; @@ -1199,23 +1231,15 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Subscriptions.Adjustment( - NewPercentageDiscount value - ) => new(value); + public static implicit operator Adjustment(NewPercentageDiscount value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Adjustment( - NewUsageDiscount value - ) => new(value); + public static implicit operator Adjustment(NewUsageDiscount value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Adjustment( - NewAmountDiscount value - ) => new(value); + public static implicit operator Adjustment(NewAmountDiscount value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Adjustment(NewMinimum value) => - new(value); + public static implicit operator Adjustment(NewMinimum value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Adjustment(NewMaximum value) => - new(value); + public static implicit operator Adjustment(NewMaximum value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -1242,7 +1266,7 @@ public override void Validate() ); } - public virtual bool Equals(global::Orb.Models.Subscriptions.Adjustment? other) + public virtual bool Equals(Adjustment? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -1256,9 +1280,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class AdjustmentConverter : JsonConverter +sealed class AdjustmentConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.Adjustment? Read( + public override Adjustment? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1383,14 +1407,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.Adjustment(element); + return new Adjustment(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.Adjustment value, + Adjustment value, JsonSerializerOptions options ) { @@ -1508,12 +1532,12 @@ public long? PlanPhaseOrder /// /// New subscription price request body params. /// - public global::Orb.Models.Subscriptions.Price? Price + public Price? Price { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("price"); + return this._rawData.GetNullableClass("price"); } init { this._rawData.Set("price", value); } } @@ -1599,7 +1623,7 @@ public AddPrice FromRawUnchecked(IReadOnlyDictionary rawDat /// /// New subscription price request body params. /// -[JsonConverter(typeof(global::Orb.Models.Subscriptions.PriceConverter))] +[JsonConverter(typeof(PriceConverter))] public record class Price : ModelBase { public object? Value { get; } = null; @@ -1650,7 +1674,6 @@ public string ItemID newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ItemID, newSubscriptionCumulativeGroupedBulk: (x) => x.ItemID, cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, newSubscriptionMinimumComposite: (x) => x.ItemID, percent: (x) => x.ItemID, eventOutput: (x) => x.ItemID @@ -1691,7 +1714,6 @@ public string Name newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Name, newSubscriptionCumulativeGroupedBulk: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, newSubscriptionMinimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name @@ -1732,7 +1754,6 @@ public string? BillableMetricID newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, newSubscriptionCumulativeGroupedBulk: (x) => x.BillableMetricID, cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, newSubscriptionMinimumComposite: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID @@ -1773,7 +1794,6 @@ public bool? BilledInAdvance newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, newSubscriptionCumulativeGroupedBulk: (x) => x.BilledInAdvance, cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, newSubscriptionMinimumComposite: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance @@ -1814,7 +1834,6 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, newSubscriptionCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, newSubscriptionMinimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration @@ -1855,7 +1874,6 @@ public double? ConversionRate newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ConversionRate, newSubscriptionCumulativeGroupedBulk: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, newSubscriptionMinimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate @@ -1896,7 +1914,6 @@ public string? Currency newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Currency, newSubscriptionCumulativeGroupedBulk: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, newSubscriptionMinimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency @@ -1939,7 +1956,6 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration x.DimensionalPriceConfiguration, newSubscriptionCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, newSubscriptionMinimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration @@ -1980,7 +1996,6 @@ public string? ExternalPriceID newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, newSubscriptionCumulativeGroupedBulk: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, newSubscriptionMinimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID @@ -2021,7 +2036,6 @@ public double? FixedPriceQuantity newSubscriptionScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, newSubscriptionCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, newSubscriptionMinimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity @@ -2062,7 +2076,6 @@ public string? InvoiceGroupingKey newSubscriptionScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, newSubscriptionCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, newSubscriptionMinimumComposite: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey @@ -2104,7 +2117,6 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration x.InvoicingCycleConfiguration, newSubscriptionCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, newSubscriptionMinimumComposite: (x) => x.InvoicingCycleConfiguration, percent: (x) => x.InvoicingCycleConfiguration, eventOutput: (x) => x.InvoicingCycleConfiguration @@ -2145,7 +2157,6 @@ public string? ReferenceID newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ReferenceID, newSubscriptionCumulativeGroupedBulk: (x) => x.ReferenceID, cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, newSubscriptionMinimumComposite: (x) => x.ReferenceID, percent: (x) => x.ReferenceID, eventOutput: (x) => x.ReferenceID @@ -2171,10 +2182,7 @@ public Price(NewSubscriptionBulkPrice value, JsonElement? element = null) this._element = element; } - public Price( - global::Orb.Models.Subscriptions.BulkWithFilters value, - JsonElement? element = null - ) + public Price(BulkWithFilters value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -2240,10 +2248,7 @@ public Price(NewSubscriptionMatrixWithAllocationPrice value, JsonElement? elemen this._element = element; } - public Price( - global::Orb.Models.Subscriptions.TieredWithProration value, - JsonElement? element = null - ) + public Price(TieredWithProration value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -2279,10 +2284,7 @@ public Price(NewSubscriptionGroupedWithMeteredMinimumPrice value, JsonElement? e this._element = element; } - public Price( - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds value, - JsonElement? element = null - ) + public Price(GroupedWithMinMaxThresholds value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -2330,16 +2332,7 @@ public Price(NewSubscriptionCumulativeGroupedBulkPrice value, JsonElement? eleme this._element = element; } - public Price( - global::Orb.Models.Subscriptions.CumulativeGroupedAllocation value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public Price(global::Orb.Models.Subscriptions.Minimum value, JsonElement? element = null) + public Price(CumulativeGroupedAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -2351,13 +2344,13 @@ public Price(NewSubscriptionMinimumCompositePrice value, JsonElement? element = this._element = element; } - public Price(global::Orb.Models.Subscriptions.Percent value, JsonElement? element = null) + public Price(Percent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(global::Orb.Models.Subscriptions.EventOutput value, JsonElement? element = null) + public Price(EventOutput value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -2435,24 +2428,22 @@ public bool TryPickNewSubscriptionBulk([NotNullWhen(true)] out NewSubscriptionBu /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickBulkWithFilters(out var value)) { - /// // `value` is of type `global::Orb.Models.Subscriptions.BulkWithFilters` + /// // `value` is of type `BulkWithFilters` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickBulkWithFilters( - [NotNullWhen(true)] out global::Orb.Models.Subscriptions.BulkWithFilters? value - ) + public bool TryPickBulkWithFilters([NotNullWhen(true)] out BulkWithFilters? value) { - value = this.Value as global::Orb.Models.Subscriptions.BulkWithFilters; + value = this.Value as BulkWithFilters; return value != null; } @@ -2688,24 +2679,22 @@ public bool TryPickNewSubscriptionMatrixWithAllocation( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickTieredWithProration(out var value)) { - /// // `value` is of type `global::Orb.Models.Subscriptions.TieredWithProration` + /// // `value` is of type `TieredWithProration` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTieredWithProration( - [NotNullWhen(true)] out global::Orb.Models.Subscriptions.TieredWithProration? value - ) + public bool TryPickTieredWithProration([NotNullWhen(true)] out TieredWithProration? value) { - value = this.Value as global::Orb.Models.Subscriptions.TieredWithProration; + value = this.Value as TieredWithProration; return value != null; } @@ -2826,24 +2815,24 @@ public bool TryPickNewSubscriptionGroupedWithMeteredMinimum( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickGroupedWithMinMaxThresholds(out var value)) { - /// // `value` is of type `global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds` + /// // `value` is of type `GroupedWithMinMaxThresholds` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] out global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds? value + [NotNullWhen(true)] out GroupedWithMinMaxThresholds? value ) { - value = this.Value as global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds; + value = this.Value as GroupedWithMinMaxThresholds; return value != null; } @@ -2987,47 +2976,24 @@ public bool TryPickNewSubscriptionCumulativeGroupedBulk( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `global::Orb.Models.Subscriptions.CumulativeGroupedAllocation` + /// // `value` is of type `CumulativeGroupedAllocation` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] out global::Orb.Models.Subscriptions.CumulativeGroupedAllocation? value - ) - { - value = this.Value as global::Orb.Models.Subscriptions.CumulativeGroupedAllocation; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `global::Orb.Models.Subscriptions.Minimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum( - [NotNullWhen(true)] out global::Orb.Models.Subscriptions.Minimum? value + [NotNullWhen(true)] out CumulativeGroupedAllocation? value ) { - value = this.Value as global::Orb.Models.Subscriptions.Minimum; + value = this.Value as CumulativeGroupedAllocation; return value != null; } @@ -3056,47 +3022,43 @@ public bool TryPickNewSubscriptionMinimumComposite( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickPercent(out var value)) { - /// // `value` is of type `global::Orb.Models.Subscriptions.Percent` + /// // `value` is of type `Percent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickPercent( - [NotNullWhen(true)] out global::Orb.Models.Subscriptions.Percent? value - ) + public bool TryPickPercent([NotNullWhen(true)] out Percent? value) { - value = this.Value as global::Orb.Models.Subscriptions.Percent; + value = this.Value as Percent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickEventOutput(out var value)) { - /// // `value` is of type `global::Orb.Models.Subscriptions.EventOutput` + /// // `value` is of type `EventOutput` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickEventOutput( - [NotNullWhen(true)] out global::Orb.Models.Subscriptions.EventOutput? value - ) + public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) { - value = this.Value as global::Orb.Models.Subscriptions.EventOutput; + value = this.Value as EventOutput; return value != null; } @@ -3117,7 +3079,7 @@ public bool TryPickEventOutput( /// (NewSubscriptionUnitPrice value) => {...}, /// (NewSubscriptionTieredPrice value) => {...}, /// (NewSubscriptionBulkPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.BulkWithFilters value) => {...}, + /// (BulkWithFilters value) => {...}, /// (NewSubscriptionPackagePrice value) => {...}, /// (NewSubscriptionMatrixPrice value) => {...}, /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, @@ -3128,24 +3090,23 @@ public bool TryPickEventOutput( /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, /// (NewSubscriptionUnitWithPercentPrice value) => {...}, /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.TieredWithProration value) => {...}, + /// (TieredWithProration value) => {...}, /// (NewSubscriptionUnitWithProrationPrice value) => {...}, /// (NewSubscriptionGroupedAllocationPrice value) => {...}, /// (NewSubscriptionBulkWithProrationPrice value) => {...}, /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.CumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Subscriptions.Minimum value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Subscriptions.Percent value) => {...}, - /// (global::Orb.Models.Subscriptions.EventOutput value) => {...} + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -3154,7 +3115,7 @@ public void Switch( System::Action newSubscriptionUnit, System::Action newSubscriptionTiered, System::Action newSubscriptionBulk, - System::Action bulkWithFilters, + System::Action bulkWithFilters, System::Action newSubscriptionPackage, System::Action newSubscriptionMatrix, System::Action newSubscriptionThresholdTotalAmount, @@ -3165,24 +3126,23 @@ public void Switch( System::Action newSubscriptionPackageWithAllocation, System::Action newSubscriptionUnitWithPercent, System::Action newSubscriptionMatrixWithAllocation, - System::Action tieredWithProration, + System::Action tieredWithProration, System::Action newSubscriptionUnitWithProration, System::Action newSubscriptionGroupedAllocation, System::Action newSubscriptionBulkWithProration, System::Action newSubscriptionGroupedWithProratedMinimum, System::Action newSubscriptionGroupedWithMeteredMinimum, - System::Action groupedWithMinMaxThresholds, + System::Action groupedWithMinMaxThresholds, System::Action newSubscriptionMatrixWithDisplayName, System::Action newSubscriptionGroupedTieredPackage, System::Action newSubscriptionMaxGroupTieredPackage, System::Action newSubscriptionScalableMatrixWithUnitPricing, System::Action newSubscriptionScalableMatrixWithTieredPricing, System::Action newSubscriptionCumulativeGroupedBulk, - System::Action cumulativeGroupedAllocation, - System::Action minimum, + System::Action cumulativeGroupedAllocation, System::Action newSubscriptionMinimumComposite, - System::Action percent, - System::Action eventOutput + System::Action percent, + System::Action eventOutput ) { switch (this.Value) @@ -3196,7 +3156,7 @@ public void Switch( case NewSubscriptionBulkPrice value: newSubscriptionBulk(value); break; - case global::Orb.Models.Subscriptions.BulkWithFilters value: + case BulkWithFilters value: bulkWithFilters(value); break; case NewSubscriptionPackagePrice value: @@ -3229,7 +3189,7 @@ public void Switch( case NewSubscriptionMatrixWithAllocationPrice value: newSubscriptionMatrixWithAllocation(value); break; - case global::Orb.Models.Subscriptions.TieredWithProration value: + case TieredWithProration value: tieredWithProration(value); break; case NewSubscriptionUnitWithProrationPrice value: @@ -3247,7 +3207,7 @@ public void Switch( case NewSubscriptionGroupedWithMeteredMinimumPrice value: newSubscriptionGroupedWithMeteredMinimum(value); break; - case global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds value: + case GroupedWithMinMaxThresholds value: groupedWithMinMaxThresholds(value); break; case NewSubscriptionMatrixWithDisplayNamePrice value: @@ -3268,19 +3228,16 @@ public void Switch( case NewSubscriptionCumulativeGroupedBulkPrice value: newSubscriptionCumulativeGroupedBulk(value); break; - case global::Orb.Models.Subscriptions.CumulativeGroupedAllocation value: + case CumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case global::Orb.Models.Subscriptions.Minimum value: - minimum(value); - break; case NewSubscriptionMinimumCompositePrice value: newSubscriptionMinimumComposite(value); break; - case global::Orb.Models.Subscriptions.Percent value: + case Percent value: percent(value); break; - case global::Orb.Models.Subscriptions.EventOutput value: + case EventOutput value: eventOutput(value); break; default: @@ -3306,7 +3263,7 @@ public void Switch( /// (NewSubscriptionUnitPrice value) => {...}, /// (NewSubscriptionTieredPrice value) => {...}, /// (NewSubscriptionBulkPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.BulkWithFilters value) => {...}, + /// (BulkWithFilters value) => {...}, /// (NewSubscriptionPackagePrice value) => {...}, /// (NewSubscriptionMatrixPrice value) => {...}, /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, @@ -3317,24 +3274,23 @@ public void Switch( /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, /// (NewSubscriptionUnitWithPercentPrice value) => {...}, /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.TieredWithProration value) => {...}, + /// (TieredWithProration value) => {...}, /// (NewSubscriptionUnitWithProrationPrice value) => {...}, /// (NewSubscriptionGroupedAllocationPrice value) => {...}, /// (NewSubscriptionBulkWithProrationPrice value) => {...}, /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.CumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Subscriptions.Minimum value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Subscriptions.Percent value) => {...}, - /// (global::Orb.Models.Subscriptions.EventOutput value) => {...} + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -3343,7 +3299,7 @@ public T Match( System::Func newSubscriptionUnit, System::Func newSubscriptionTiered, System::Func newSubscriptionBulk, - System::Func bulkWithFilters, + System::Func bulkWithFilters, System::Func newSubscriptionPackage, System::Func newSubscriptionMatrix, System::Func< @@ -3366,7 +3322,7 @@ public T Match( NewSubscriptionMatrixWithAllocationPrice, T > newSubscriptionMatrixWithAllocation, - System::Func tieredWithProration, + System::Func tieredWithProration, System::Func newSubscriptionUnitWithProration, System::Func newSubscriptionGroupedAllocation, System::Func newSubscriptionBulkWithProration, @@ -3378,10 +3334,7 @@ public T Match( NewSubscriptionGroupedWithMeteredMinimumPrice, T > newSubscriptionGroupedWithMeteredMinimum, - System::Func< - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds, - T - > groupedWithMinMaxThresholds, + System::Func groupedWithMinMaxThresholds, System::Func< NewSubscriptionMatrixWithDisplayNamePrice, T @@ -3406,14 +3359,10 @@ public T Match( NewSubscriptionCumulativeGroupedBulkPrice, T > newSubscriptionCumulativeGroupedBulk, - System::Func< - global::Orb.Models.Subscriptions.CumulativeGroupedAllocation, - T - > cumulativeGroupedAllocation, - System::Func minimum, + System::Func cumulativeGroupedAllocation, System::Func newSubscriptionMinimumComposite, - System::Func percent, - System::Func eventOutput + System::Func percent, + System::Func eventOutput ) { return this.Value switch @@ -3421,7 +3370,7 @@ public T Match( NewSubscriptionUnitPrice value => newSubscriptionUnit(value), NewSubscriptionTieredPrice value => newSubscriptionTiered(value), NewSubscriptionBulkPrice value => newSubscriptionBulk(value), - global::Orb.Models.Subscriptions.BulkWithFilters value => bulkWithFilters(value), + BulkWithFilters value => bulkWithFilters(value), NewSubscriptionPackagePrice value => newSubscriptionPackage(value), NewSubscriptionMatrixPrice value => newSubscriptionMatrix(value), NewSubscriptionThresholdTotalAmountPrice value => newSubscriptionThresholdTotalAmount( @@ -3439,9 +3388,7 @@ public T Match( NewSubscriptionMatrixWithAllocationPrice value => newSubscriptionMatrixWithAllocation( value ), - global::Orb.Models.Subscriptions.TieredWithProration value => tieredWithProration( - value - ), + TieredWithProration value => tieredWithProration(value), NewSubscriptionUnitWithProrationPrice value => newSubscriptionUnitWithProration(value), NewSubscriptionGroupedAllocationPrice value => newSubscriptionGroupedAllocation(value), NewSubscriptionBulkWithProrationPrice value => newSubscriptionBulkWithProration(value), @@ -3449,8 +3396,7 @@ public T Match( newSubscriptionGroupedWithProratedMinimum(value), NewSubscriptionGroupedWithMeteredMinimumPrice value => newSubscriptionGroupedWithMeteredMinimum(value), - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds value => - groupedWithMinMaxThresholds(value), + GroupedWithMinMaxThresholds value => groupedWithMinMaxThresholds(value), NewSubscriptionMatrixWithDisplayNamePrice value => newSubscriptionMatrixWithDisplayName( value ), @@ -3467,143 +3413,93 @@ public T Match( NewSubscriptionCumulativeGroupedBulkPrice value => newSubscriptionCumulativeGroupedBulk( value ), - global::Orb.Models.Subscriptions.CumulativeGroupedAllocation value => - cumulativeGroupedAllocation(value), - global::Orb.Models.Subscriptions.Minimum value => minimum(value), + CumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), NewSubscriptionMinimumCompositePrice value => newSubscriptionMinimumComposite(value), - global::Orb.Models.Subscriptions.Percent value => percent(value), - global::Orb.Models.Subscriptions.EventOutput value => eventOutput(value), + Percent value => percent(value), + EventOutput value => eventOutput(value), _ => throw new OrbInvalidDataException("Data did not match any variant of Price"), }; } - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionUnitPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionUnitPrice value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionTieredPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionTieredPrice value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionBulkPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionBulkPrice value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - global::Orb.Models.Subscriptions.BulkWithFilters value - ) => new(value); + public static implicit operator Price(BulkWithFilters value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionPackagePrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionMatrixPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionMatrixPrice value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionThresholdTotalAmountPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionThresholdTotalAmountPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionTieredPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionTieredWithMinimumPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionTieredWithMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionGroupedTieredPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionGroupedTieredPrice value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionTieredPackageWithMinimumPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionTieredPackageWithMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionPackageWithAllocationPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionPackageWithAllocationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionUnitWithPercentPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionUnitWithPercentPrice value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionMatrixWithAllocationPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionMatrixWithAllocationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - global::Orb.Models.Subscriptions.TieredWithProration value - ) => new(value); + public static implicit operator Price(TieredWithProration value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionUnitWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionUnitWithProrationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionGroupedAllocationPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionGroupedAllocationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionBulkWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionBulkWithProrationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionGroupedWithProratedMinimumPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionGroupedWithProratedMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionGroupedWithMeteredMinimumPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionGroupedWithMeteredMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds value - ) => new(value); + public static implicit operator Price(GroupedWithMinMaxThresholds value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionMatrixWithDisplayNamePrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionMatrixWithDisplayNamePrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionGroupedTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionGroupedTieredPackagePrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionMaxGroupTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionMaxGroupTieredPackagePrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( + public static implicit operator Price( NewSubscriptionScalableMatrixWithUnitPricingPrice value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( + public static implicit operator Price( NewSubscriptionScalableMatrixWithTieredPricingPrice value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionCumulativeGroupedBulkPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Subscriptions.Price( - global::Orb.Models.Subscriptions.CumulativeGroupedAllocation value - ) => new(value); + public static implicit operator Price(NewSubscriptionCumulativeGroupedBulkPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - global::Orb.Models.Subscriptions.Minimum value - ) => new(value); + public static implicit operator Price(CumulativeGroupedAllocation value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionMinimumCompositePrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionMinimumCompositePrice value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - global::Orb.Models.Subscriptions.Percent value - ) => new(value); + public static implicit operator Price(Percent value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - global::Orb.Models.Subscriptions.EventOutput value - ) => new(value); + public static implicit operator Price(EventOutput value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -3659,14 +3555,13 @@ public override void Validate() (newSubscriptionCumulativeGroupedBulk) => newSubscriptionCumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), (newSubscriptionMinimumComposite) => newSubscriptionMinimumComposite.Validate(), (percent) => percent.Validate(), (eventOutput) => eventOutput.Validate() ); } - public virtual bool Equals(global::Orb.Models.Subscriptions.Price? other) + public virtual bool Equals(Price? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -3680,9 +3575,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class PriceConverter : JsonConverter +sealed class PriceConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.Price? Read( + public override Price? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -3771,11 +3666,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -4022,11 +3916,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -4160,11 +4053,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -4321,34 +4213,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -4390,11 +4258,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -4413,11 +4277,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -4434,40 +4294,29 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.Price(element); + return new Price(element); } } } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.Price? value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Price? value, JsonSerializerOptions options) { JsonSerializer.Serialize(writer, value?.Json, options); } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.BulkWithFilters, - global::Orb.Models.Subscriptions.BulkWithFiltersFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class BulkWithFilters : JsonModel { /// /// Configuration for bulk_with_filters pricing /// - public required global::Orb.Models.Subscriptions.BulkWithFiltersConfig BulkWithFiltersConfig + public required BulkWithFiltersConfig BulkWithFiltersConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "bulk_with_filters_config" - ); + return this._rawData.GetNotNullClass("bulk_with_filters_config"); } init { this._rawData.Set("bulk_with_filters_config", value); } } @@ -4475,14 +4324,12 @@ public sealed record class BulkWithFilters : JsonModel /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } @@ -4585,14 +4432,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Subscriptions.ConversionRateConfig? ConversionRateConfig + public ConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); + return this._rawData.GetNullableClass("conversion_rate_config"); } init { this._rawData.Set("conversion_rate_config", value); } } @@ -4752,7 +4597,7 @@ public BulkWithFilters() this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } - public BulkWithFilters(global::Orb.Models.Subscriptions.BulkWithFilters bulkWithFilters) + public BulkWithFilters(BulkWithFilters bulkWithFilters) : base(bulkWithFilters) { } public BulkWithFilters(IReadOnlyDictionary rawData) @@ -4770,49 +4615,39 @@ public BulkWithFilters(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.BulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class BulkWithFiltersFromRaw : IFromRawJson +class BulkWithFiltersFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.BulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.BulkWithFilters.FromRawUnchecked(rawData); + public BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) => + BulkWithFilters.FromRawUnchecked(rawData); } /// /// Configuration for bulk_with_filters pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.BulkWithFiltersConfig, - global::Orb.Models.Subscriptions.BulkWithFiltersConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class BulkWithFiltersConfig : JsonModel { /// /// Property filters to apply (all must match) /// - public required IReadOnlyList Filters + public required IReadOnlyList Filters { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("filters"); + return this._rawData.GetNotNullStruct>("filters"); } init { - this._rawData.Set>( + this._rawData.Set>( "filters", ImmutableArray.ToImmutableArray(value) ); @@ -4822,18 +4657,16 @@ public sealed record class BulkWithFiltersConfig : JsonModel /// /// Bulk tiers for rating based on total usage volume /// - public required IReadOnlyList Tiers + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + return this._rawData.GetNotNullStruct>("tiers"); } init { - this._rawData.Set>( + this._rawData.Set>( "tiers", ImmutableArray.ToImmutableArray(value) ); @@ -4855,9 +4688,7 @@ public override void Validate() public BulkWithFiltersConfig() { } - public BulkWithFiltersConfig( - global::Orb.Models.Subscriptions.BulkWithFiltersConfig bulkWithFiltersConfig - ) + public BulkWithFiltersConfig(BulkWithFiltersConfig bulkWithFiltersConfig) : base(bulkWithFiltersConfig) { } public BulkWithFiltersConfig(IReadOnlyDictionary rawData) @@ -4873,8 +4704,8 @@ public BulkWithFiltersConfig(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.BulkWithFiltersConfig FromRawUnchecked( + /// + public static BulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4882,24 +4713,18 @@ IReadOnlyDictionary rawData } } -class BulkWithFiltersConfigFromRaw - : IFromRawJson +class BulkWithFiltersConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.BulkWithFiltersConfig FromRawUnchecked( + public BulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.BulkWithFiltersConfig.FromRawUnchecked(rawData); + ) => BulkWithFiltersConfig.FromRawUnchecked(rawData); } /// /// Configuration for a single property filter /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.Filter, - global::Orb.Models.Subscriptions.FilterFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Filter : JsonModel { /// @@ -4937,7 +4762,7 @@ public override void Validate() public Filter() { } - public Filter(global::Orb.Models.Subscriptions.Filter filter) + public Filter(Filter filter) : base(filter) { } public Filter(IReadOnlyDictionary rawData) @@ -4953,32 +4778,24 @@ public Filter(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Filter FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class FilterFromRaw : IFromRawJson +class FilterFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.Filter.FromRawUnchecked(rawData); + public Filter FromRawUnchecked(IReadOnlyDictionary rawData) => + Filter.FromRawUnchecked(rawData); } /// /// Configuration for a single bulk pricing tier /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.Tier, - global::Orb.Models.Subscriptions.TierFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Tier : JsonModel { /// @@ -5016,7 +4833,7 @@ public override void Validate() public Tier() { } - public Tier(global::Orb.Models.Subscriptions.Tier tier) + public Tier(Tier tier) : base(tier) { } public Tier(IReadOnlyDictionary rawData) @@ -5032,10 +4849,8 @@ public Tier(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Tier FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } @@ -5048,18 +4863,17 @@ public Tier(string unitAmount) } } -class TierFromRaw : IFromRawJson +class TierFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.Tier.FromRawUnchecked(rawData); + public Tier FromRawUnchecked(IReadOnlyDictionary rawData) => + Tier.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Subscriptions.CadenceConverter))] +[JsonConverter(typeof(CadenceConverter))] public enum Cadence { Annual, @@ -5070,9 +4884,9 @@ public enum Cadence Custom, } -sealed class CadenceConverter : JsonConverter +sealed class CadenceConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.Cadence Read( + public override Cadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5080,32 +4894,28 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Subscriptions.Cadence.Annual, - "semi_annual" => global::Orb.Models.Subscriptions.Cadence.SemiAnnual, - "monthly" => global::Orb.Models.Subscriptions.Cadence.Monthly, - "quarterly" => global::Orb.Models.Subscriptions.Cadence.Quarterly, - "one_time" => global::Orb.Models.Subscriptions.Cadence.OneTime, - "custom" => global::Orb.Models.Subscriptions.Cadence.Custom, - _ => (global::Orb.Models.Subscriptions.Cadence)(-1), + "annual" => Cadence.Annual, + "semi_annual" => Cadence.SemiAnnual, + "monthly" => Cadence.Monthly, + "quarterly" => Cadence.Quarterly, + "one_time" => Cadence.OneTime, + "custom" => Cadence.Custom, + _ => (Cadence)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.Cadence value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Cadence value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Subscriptions.Cadence.Annual => "annual", - global::Orb.Models.Subscriptions.Cadence.SemiAnnual => "semi_annual", - global::Orb.Models.Subscriptions.Cadence.Monthly => "monthly", - global::Orb.Models.Subscriptions.Cadence.Quarterly => "quarterly", - global::Orb.Models.Subscriptions.Cadence.OneTime => "one_time", - global::Orb.Models.Subscriptions.Cadence.Custom => "custom", + Cadence.Annual => "annual", + Cadence.SemiAnnual => "semi_annual", + Cadence.Monthly => "monthly", + Cadence.Quarterly => "quarterly", + Cadence.OneTime => "one_time", + Cadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -5115,7 +4925,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.Subscriptions.ConversionRateConfigConverter))] +[JsonConverter(typeof(ConversionRateConfigConverter))] public record class ConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5268,13 +5078,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Subscriptions.ConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); + public static implicit operator ConversionRateConfig(SharedUnitConversionRateConfig value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.ConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); + public static implicit operator ConversionRateConfig(SharedTieredConversionRateConfig value) => + new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -5297,7 +5105,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Subscriptions.ConversionRateConfig? other) + public virtual bool Equals(ConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -5311,10 +5119,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class ConversionRateConfigConverter - : JsonConverter +sealed class ConversionRateConfigConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.ConversionRateConfig? Read( + public override ConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5379,14 +5186,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.ConversionRateConfig(element); + return new ConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.ConversionRateConfig value, + ConversionRateConfig value, JsonSerializerOptions options ) { @@ -5394,28 +5201,20 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.TieredWithProration, - global::Orb.Models.Subscriptions.TieredWithProrationFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class TieredWithProration : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Subscriptions.TieredWithProrationCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } init { this._rawData.Set("cadence", value); } } @@ -5462,12 +5261,12 @@ public required string Name /// /// Configuration for tiered_with_proration pricing /// - public required global::Orb.Models.Subscriptions.TieredWithProrationConfig TieredWithProrationConfig + public required TieredWithProrationConfig TieredWithProrationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "tiered_with_proration_config" ); } @@ -5533,12 +5332,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Subscriptions.TieredWithProrationConversionRateConfig? ConversionRateConfig + public TieredWithProrationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5700,9 +5499,7 @@ public TieredWithProration() this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } - public TieredWithProration( - global::Orb.Models.Subscriptions.TieredWithProration tieredWithProration - ) + public TieredWithProration(TieredWithProration tieredWithProration) : base(tieredWithProration) { } public TieredWithProration(IReadOnlyDictionary rawData) @@ -5720,8 +5517,8 @@ public TieredWithProration(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.TieredWithProration FromRawUnchecked( + /// + public static TieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5729,19 +5526,17 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationFromRaw - : IFromRawJson +class TieredWithProrationFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.TieredWithProration FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.TieredWithProration.FromRawUnchecked(rawData); + public TieredWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredWithProration.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Subscriptions.TieredWithProrationCadenceConverter))] +[JsonConverter(typeof(TieredWithProrationCadenceConverter))] public enum TieredWithProrationCadence { Annual, @@ -5752,10 +5547,9 @@ public enum TieredWithProrationCadence Custom, } -sealed class TieredWithProrationCadenceConverter - : JsonConverter +sealed class TieredWithProrationCadenceConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.TieredWithProrationCadence Read( + public override TieredWithProrationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5763,19 +5557,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Subscriptions.TieredWithProrationCadence.Annual, - "semi_annual" => global::Orb.Models.Subscriptions.TieredWithProrationCadence.SemiAnnual, - "monthly" => global::Orb.Models.Subscriptions.TieredWithProrationCadence.Monthly, - "quarterly" => global::Orb.Models.Subscriptions.TieredWithProrationCadence.Quarterly, - "one_time" => global::Orb.Models.Subscriptions.TieredWithProrationCadence.OneTime, - "custom" => global::Orb.Models.Subscriptions.TieredWithProrationCadence.Custom, - _ => (global::Orb.Models.Subscriptions.TieredWithProrationCadence)(-1), + "annual" => TieredWithProrationCadence.Annual, + "semi_annual" => TieredWithProrationCadence.SemiAnnual, + "monthly" => TieredWithProrationCadence.Monthly, + "quarterly" => TieredWithProrationCadence.Quarterly, + "one_time" => TieredWithProrationCadence.OneTime, + "custom" => TieredWithProrationCadence.Custom, + _ => (TieredWithProrationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.TieredWithProrationCadence value, + TieredWithProrationCadence value, JsonSerializerOptions options ) { @@ -5783,14 +5577,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Subscriptions.TieredWithProrationCadence.Annual => "annual", - global::Orb.Models.Subscriptions.TieredWithProrationCadence.SemiAnnual => - "semi_annual", - global::Orb.Models.Subscriptions.TieredWithProrationCadence.Monthly => "monthly", - global::Orb.Models.Subscriptions.TieredWithProrationCadence.Quarterly => - "quarterly", - global::Orb.Models.Subscriptions.TieredWithProrationCadence.OneTime => "one_time", - global::Orb.Models.Subscriptions.TieredWithProrationCadence.Custom => "custom", + TieredWithProrationCadence.Annual => "annual", + TieredWithProrationCadence.SemiAnnual => "semi_annual", + TieredWithProrationCadence.Monthly => "monthly", + TieredWithProrationCadence.Quarterly => "quarterly", + TieredWithProrationCadence.OneTime => "one_time", + TieredWithProrationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -5804,10 +5596,7 @@ JsonSerializerOptions options /// Configuration for tiered_with_proration pricing /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.TieredWithProrationConfig, - global::Orb.Models.Subscriptions.TieredWithProrationConfigFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class TieredWithProrationConfig : JsonModel { @@ -5815,20 +5604,21 @@ public sealed record class TieredWithProrationConfig : JsonModel /// Tiers for rating based on total usage quantities into the specified tier /// with proration /// - public required IReadOnlyList Tiers + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + return this._rawData.GetNotNullStruct>( + "tiers" + ); } init { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); } } @@ -5843,9 +5633,7 @@ public override void Validate() public TieredWithProrationConfig() { } - public TieredWithProrationConfig( - global::Orb.Models.Subscriptions.TieredWithProrationConfig tieredWithProrationConfig - ) + public TieredWithProrationConfig(TieredWithProrationConfig tieredWithProrationConfig) : base(tieredWithProrationConfig) { } public TieredWithProrationConfig(IReadOnlyDictionary rawData) @@ -5861,8 +5649,8 @@ public TieredWithProrationConfig(IReadOnlyDictionary rawDat } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.TieredWithProrationConfig FromRawUnchecked( + /// + public static TieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5870,32 +5658,26 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public TieredWithProrationConfig( - IReadOnlyList tiers - ) + public TieredWithProrationConfig(IReadOnlyList tiers) : this() { this.Tiers = tiers; } } -class TieredWithProrationConfigFromRaw - : IFromRawJson +class TieredWithProrationConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.TieredWithProrationConfig FromRawUnchecked( + public TieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.TieredWithProrationConfig.FromRawUnchecked(rawData); + ) => TieredWithProrationConfig.FromRawUnchecked(rawData); } /// /// Configuration for a single tiered with proration tier /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.TieredWithProrationConfigTier, - global::Orb.Models.Subscriptions.TieredWithProrationConfigTierFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class TieredWithProrationConfigTier : JsonModel { @@ -5935,7 +5717,7 @@ public override void Validate() public TieredWithProrationConfigTier() { } public TieredWithProrationConfigTier( - global::Orb.Models.Subscriptions.TieredWithProrationConfigTier tieredWithProrationConfigTier + TieredWithProrationConfigTier tieredWithProrationConfigTier ) : base(tieredWithProrationConfigTier) { } @@ -5952,8 +5734,8 @@ public TieredWithProrationConfigTier(IReadOnlyDictionary ra } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.TieredWithProrationConfigTier FromRawUnchecked( + /// + public static TieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5961,18 +5743,15 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationConfigTierFromRaw - : IFromRawJson +class TieredWithProrationConfigTierFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.TieredWithProrationConfigTier FromRawUnchecked( + public TieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.TieredWithProrationConfigTier.FromRawUnchecked(rawData); + ) => TieredWithProrationConfigTier.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Subscriptions.TieredWithProrationConversionRateConfigConverter) -)] +[JsonConverter(typeof(TieredWithProrationConversionRateConfigConverter))] public record class TieredWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6131,11 +5910,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Subscriptions.TieredWithProrationConversionRateConfig( + public static implicit operator TieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.TieredWithProrationConversionRateConfig( + public static implicit operator TieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6160,9 +5939,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Subscriptions.TieredWithProrationConversionRateConfig? other - ) + public virtual bool Equals(TieredWithProrationConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -6177,9 +5954,9 @@ public override string ToString() => } sealed class TieredWithProrationConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Subscriptions.TieredWithProrationConversionRateConfig? Read( + public override TieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6244,16 +6021,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.TieredWithProrationConversionRateConfig( - element - ); + return new TieredWithProrationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.TieredWithProrationConversionRateConfig value, + TieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -6262,26 +6037,20 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds, - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class GroupedWithMinMaxThresholds : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -6290,12 +6059,12 @@ public required ApiEnum< /// /// Configuration for grouped_with_min_max_thresholds pricing /// - public required global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + public required GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "grouped_with_min_max_thresholds_config" ); } @@ -6400,12 +6169,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + public GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -6567,9 +6336,7 @@ public GroupedWithMinMaxThresholds() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } - public GroupedWithMinMaxThresholds( - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds groupedWithMinMaxThresholds - ) + public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) : base(groupedWithMinMaxThresholds) { } public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) @@ -6587,8 +6354,8 @@ public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawD } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6596,21 +6363,18 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class GroupedWithMinMaxThresholdsFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds FromRawUnchecked( + public GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + ) => GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadenceConverter) -)] +[JsonConverter(typeof(GroupedWithMinMaxThresholdsCadenceConverter))] public enum GroupedWithMinMaxThresholdsCadence { Annual, @@ -6622,9 +6386,9 @@ public enum GroupedWithMinMaxThresholdsCadence } sealed class GroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence Read( + public override GroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6632,35 +6396,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence.Annual, - "semi_annual" => global::Orb - .Models - .Subscriptions - .GroupedWithMinMaxThresholdsCadence - .SemiAnnual, - "monthly" => global::Orb - .Models - .Subscriptions - .GroupedWithMinMaxThresholdsCadence - .Monthly, - "quarterly" => global::Orb - .Models - .Subscriptions - .GroupedWithMinMaxThresholdsCadence - .Quarterly, - "one_time" => global::Orb - .Models - .Subscriptions - .GroupedWithMinMaxThresholdsCadence - .OneTime, - "custom" => global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence.Custom, - _ => (global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence)(-1), + "annual" => GroupedWithMinMaxThresholdsCadence.Annual, + "semi_annual" => GroupedWithMinMaxThresholdsCadence.SemiAnnual, + "monthly" => GroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => GroupedWithMinMaxThresholdsCadence.Quarterly, + "one_time" => GroupedWithMinMaxThresholdsCadence.OneTime, + "custom" => GroupedWithMinMaxThresholdsCadence.Custom, + _ => (GroupedWithMinMaxThresholdsCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence value, + GroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -6668,18 +6416,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence.Annual => - "annual", - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence.SemiAnnual => - "semi_annual", - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence.Monthly => - "monthly", - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence.Quarterly => - "quarterly", - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence.OneTime => - "one_time", - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence.Custom => - "custom", + GroupedWithMinMaxThresholdsCadence.Annual => "annual", + GroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", + GroupedWithMinMaxThresholdsCadence.Monthly => "monthly", + GroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", + GroupedWithMinMaxThresholdsCadence.OneTime => "one_time", + GroupedWithMinMaxThresholdsCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -6694,8 +6436,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfig, - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfigFromRaw + GroupedWithMinMaxThresholdsConfig, + GroupedWithMinMaxThresholdsConfigFromRaw >) )] public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel @@ -6764,7 +6506,7 @@ public override void Validate() public GroupedWithMinMaxThresholdsConfig() { } public GroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig + GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) : base(groupedWithMinMaxThresholdsConfig) { } @@ -6781,8 +6523,8 @@ public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary - public static global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6790,21 +6532,15 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class GroupedWithMinMaxThresholdsConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfig.FromRawUnchecked( - rawData - ); + ) => GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConversionRateConfigConverter) -)] +[JsonConverter(typeof(GroupedWithMinMaxThresholdsConversionRateConfigConverter))] public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6963,11 +6699,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6992,9 +6728,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConversionRateConfig? other - ) + public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -7009,9 +6743,9 @@ public override string ToString() => } sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override GroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7076,16 +6810,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConversionRateConfig( - element - ); + return new GroupedWithMinMaxThresholdsConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConversionRateConfig value, + GroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -7094,26 +6826,20 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.CumulativeGroupedAllocation, - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class CumulativeGroupedAllocation : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -7122,12 +6848,12 @@ public required ApiEnum< /// /// Configuration for cumulative_grouped_allocation pricing /// - public required global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "cumulative_grouped_allocation_config" ); } @@ -7232,12 +6958,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + public CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -7399,9 +7125,7 @@ public CumulativeGroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public CumulativeGroupedAllocation( - global::Orb.Models.Subscriptions.CumulativeGroupedAllocation cumulativeGroupedAllocation - ) + public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) : base(cumulativeGroupedAllocation) { } public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) @@ -7419,8 +7143,8 @@ public CumulativeGroupedAllocation(IReadOnlyDictionary rawD } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.CumulativeGroupedAllocation FromRawUnchecked( + /// + public static CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -7428,21 +7152,18 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationFromRaw - : IFromRawJson +class CumulativeGroupedAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.CumulativeGroupedAllocation FromRawUnchecked( + public CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.CumulativeGroupedAllocation.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadenceConverter) -)] +[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] public enum CumulativeGroupedAllocationCadence { Annual, @@ -7454,9 +7175,9 @@ public enum CumulativeGroupedAllocationCadence } sealed class CumulativeGroupedAllocationCadenceConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence Read( + public override CumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7464,35 +7185,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence.Annual, - "semi_annual" => global::Orb - .Models - .Subscriptions - .CumulativeGroupedAllocationCadence - .SemiAnnual, - "monthly" => global::Orb - .Models - .Subscriptions - .CumulativeGroupedAllocationCadence - .Monthly, - "quarterly" => global::Orb - .Models - .Subscriptions - .CumulativeGroupedAllocationCadence - .Quarterly, - "one_time" => global::Orb - .Models - .Subscriptions - .CumulativeGroupedAllocationCadence - .OneTime, - "custom" => global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence.Custom, - _ => (global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence)(-1), + "annual" => CumulativeGroupedAllocationCadence.Annual, + "semi_annual" => CumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => CumulativeGroupedAllocationCadence.Monthly, + "quarterly" => CumulativeGroupedAllocationCadence.Quarterly, + "one_time" => CumulativeGroupedAllocationCadence.OneTime, + "custom" => CumulativeGroupedAllocationCadence.Custom, + _ => (CumulativeGroupedAllocationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence value, + CumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -7500,18 +7205,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence.Annual => - "annual", - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence.SemiAnnual => - "semi_annual", - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence.Monthly => - "monthly", - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence.Quarterly => - "quarterly", - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence.OneTime => - "one_time", - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence.Custom => - "custom", + CumulativeGroupedAllocationCadence.Annual => "annual", + CumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", + CumulativeGroupedAllocationCadence.Monthly => "monthly", + CumulativeGroupedAllocationCadence.Quarterly => "quarterly", + CumulativeGroupedAllocationCadence.OneTime => "one_time", + CumulativeGroupedAllocationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -7526,8 +7225,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfig, - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfigFromRaw + CumulativeGroupedAllocationConfig, + CumulativeGroupedAllocationConfigFromRaw >) )] public sealed record class CumulativeGroupedAllocationConfig : JsonModel @@ -7596,7 +7295,7 @@ public override void Validate() public CumulativeGroupedAllocationConfig() { } public CumulativeGroupedAllocationConfig( - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig ) : base(cumulativeGroupedAllocationConfig) { } @@ -7613,8 +7312,8 @@ public CumulativeGroupedAllocationConfig(IReadOnlyDictionary - public static global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -7622,21 +7321,15 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class CumulativeGroupedAllocationConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfig FromRawUnchecked( + public CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfig.FromRawUnchecked( - rawData - ); + ) => CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConversionRateConfigConverter) -)] +[JsonConverter(typeof(CumulativeGroupedAllocationConversionRateConfigConverter))] public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -7795,11 +7488,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7824,9 +7517,7 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConversionRateConfig? other - ) + public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -7841,9 +7532,9 @@ public override string ToString() => } sealed class CumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConversionRateConfig? Read( + public override CumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7908,16 +7599,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConversionRateConfig( - element - ); + return new CumulativeGroupedAllocationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConversionRateConfig value, + CumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -7925,23 +7614,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.Minimum, - global::Orb.Models.Subscriptions.MinimumFromRaw - >) -)] -public sealed record class Minimum : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Percent : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>("cadence"); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } @@ -7960,44 +7644,42 @@ public required string ItemID } /// - /// Configuration for minimum pricing + /// The pricing model type /// - public required global::Orb.Models.Subscriptions.MinimumConfig MinimumConfig + public JsonElement ModelType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" - ); + return this._rawData.GetNotNullStruct("model_type"); } - init { this._rawData.Set("minimum_config", value); } + init { this._rawData.Set("model_type", value); } } /// - /// The pricing model type + /// The name of the price. /// - public JsonElement ModelType + public required string Name { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); + return this._rawData.GetNotNullClass("name"); } - init { this._rawData.Set("model_type", value); } + init { this._rawData.Set("name", value); } } /// - /// The name of the price. + /// Configuration for percent pricing /// - public required string Name + public required PercentConfig PercentConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); + return this._rawData.GetNotNullClass("percent_config"); } - init { this._rawData.Set("name", value); } + init { this._rawData.Set("percent_config", value); } } /// @@ -8059,12 +7741,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public MinimumConversionRateConfig? ConversionRateConfig + public PercentConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8195,12 +7877,12 @@ public override void Validate() { this.Cadence.Validate(); _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("percent"))) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; + this.PercentConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -8216,51 +7898,48 @@ public override void Validate() _ = this.ReferenceID; } - public Minimum() + public Percent() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public Minimum(global::Orb.Models.Subscriptions.Minimum minimum) - : base(minimum) { } + public Percent(Percent percent) + : base(percent) { } - public Minimum(IReadOnlyDictionary rawData) + public Percent(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Minimum(FrozenDictionary rawData) + Percent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Percent FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class MinimumFromRaw : IFromRawJson +class PercentFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.Minimum.FromRawUnchecked(rawData); + public Percent FromRawUnchecked(IReadOnlyDictionary rawData) => + Percent.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(MinimumCadenceConverter))] -public enum MinimumCadence +[JsonConverter(typeof(PercentCadenceConverter))] +public enum PercentCadence { Annual, SemiAnnual, @@ -8270,9 +7949,9 @@ public enum MinimumCadence Custom, } -sealed class MinimumCadenceConverter : JsonConverter +sealed class PercentCadenceConverter : JsonConverter { - public override MinimumCadence Read( + public override PercentCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8280,19 +7959,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => MinimumCadence.Annual, - "semi_annual" => MinimumCadence.SemiAnnual, - "monthly" => MinimumCadence.Monthly, - "quarterly" => MinimumCadence.Quarterly, - "one_time" => MinimumCadence.OneTime, - "custom" => MinimumCadence.Custom, - _ => (MinimumCadence)(-1), + "annual" => PercentCadence.Annual, + "semi_annual" => PercentCadence.SemiAnnual, + "monthly" => PercentCadence.Monthly, + "quarterly" => PercentCadence.Quarterly, + "one_time" => PercentCadence.OneTime, + "custom" => PercentCadence.Custom, + _ => (PercentCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - MinimumCadence value, + PercentCadence value, JsonSerializerOptions options ) { @@ -8300,12 +7979,12 @@ JsonSerializerOptions options writer, value switch { - MinimumCadence.Annual => "annual", - MinimumCadence.SemiAnnual => "semi_annual", - MinimumCadence.Monthly => "monthly", - MinimumCadence.Quarterly => "quarterly", - MinimumCadence.OneTime => "one_time", - MinimumCadence.Custom => "custom", + PercentCadence.Annual => "annual", + PercentCadence.SemiAnnual => "semi_annual", + PercentCadence.Monthly => "monthly", + PercentCadence.Quarterly => "quarterly", + PercentCadence.OneTime => "one_time", + PercentCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -8316,101 +7995,71 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for percent pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.MinimumConfig, - global::Orb.Models.Subscriptions.MinimumConfigFromRaw - >) -)] -public sealed record class MinimumConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PercentConfig : JsonModel { /// - /// The minimum amount to apply - /// - public required string MinimumAmount - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); - } - init { this._rawData.Set("minimum_amount", value); } - } - - /// - /// If true, subtotals from this price are prorated based on the service period + /// What percent of the component subtotals to charge /// - public bool? Prorated + public required double Percent { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); - } - init - { - if (value == null) - { - return; - } - - this._rawData.Set("prorated", value); + return this._rawData.GetNotNullStruct("percent"); } + init { this._rawData.Set("percent", value); } } /// public override void Validate() { - _ = this.MinimumAmount; - _ = this.Prorated; + _ = this.Percent; } - public MinimumConfig() { } + public PercentConfig() { } - public MinimumConfig(global::Orb.Models.Subscriptions.MinimumConfig minimumConfig) - : base(minimumConfig) { } + public PercentConfig(PercentConfig percentConfig) + : base(percentConfig) { } - public MinimumConfig(IReadOnlyDictionary rawData) + public PercentConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - MinimumConfig(FrozenDictionary rawData) + PercentConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } [SetsRequiredMembers] - public MinimumConfig(string minimumAmount) + public PercentConfig(double percent) : this() { - this.MinimumAmount = minimumAmount; + this.Percent = percent; } } -class MinimumConfigFromRaw : IFromRawJson +class PercentConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.MinimumConfig.FromRawUnchecked(rawData); + public PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + PercentConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(MinimumConversionRateConfigConverter))] -public record class MinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(PercentConversionRateConfigConverter))] +public record class PercentConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -8427,7 +8076,7 @@ public JsonElement Json } } - public MinimumConversionRateConfig( + public PercentConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8436,7 +8085,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig( + public PercentConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8445,7 +8094,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig(JsonElement element) + public PercentConversionRateConfig(JsonElement element) { this._element = element; } @@ -8527,7 +8176,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of PercentConversionRateConfig" ); } } @@ -8563,16 +8212,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of PercentConversionRateConfig" ), }; } - public static implicit operator MinimumConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator MinimumConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -8591,13 +8240,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of PercentConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(MinimumConversionRateConfig? other) + public virtual bool Equals(PercentConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -8611,9 +8260,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class MinimumConversionRateConfigConverter : JsonConverter +sealed class PercentConversionRateConfigConverter : JsonConverter { - public override MinimumConversionRateConfig? Read( + public override PercentConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8678,14 +8327,14 @@ JsonSerializerOptions options } default: { - return new MinimumConversionRateConfig(element); + return new PercentConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - MinimumConversionRateConfig value, + PercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -8693,29 +8342,35 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.Percent, - global::Orb.Models.Subscriptions.PercentFromRaw - >) -)] -public sealed record class Percent : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class EventOutput : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } + /// + /// Configuration for event_output pricing + /// + public required EventOutputConfig EventOutputConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("event_output_config"); + } + init { this._rawData.Set("event_output_config", value); } + } + /// /// The id of the item the price will be associated with. /// @@ -8755,21 +8410,6 @@ public required string Name init { this._rawData.Set("name", value); } } - /// - /// Configuration for percent pricing - /// - public required global::Orb.Models.Subscriptions.PercentConfig PercentConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "percent_config" - ); - } - init { this._rawData.Set("percent_config", value); } - } - /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -8829,12 +8469,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Subscriptions.PercentConversionRateConfig? ConversionRateConfig + public EventOutputConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8964,13 +8604,18 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); + this.EventOutputConfig.Validate(); _ = this.ItemID; - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("percent"))) + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("event_output") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.PercentConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -8986,51 +8631,48 @@ public override void Validate() _ = this.ReferenceID; } - public Percent() + public EventOutput() { - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("event_output"); } - public Percent(global::Orb.Models.Subscriptions.Percent percent) - : base(percent) { } + public EventOutput(EventOutput eventOutput) + : base(eventOutput) { } - public Percent(IReadOnlyDictionary rawData) + public EventOutput(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("event_output"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Percent(FrozenDictionary rawData) + EventOutput(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PercentFromRaw : IFromRawJson +class EventOutputFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.Percent.FromRawUnchecked(rawData); + public EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutput.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Subscriptions.PercentCadenceConverter))] -public enum PercentCadence +[JsonConverter(typeof(EventOutputCadenceConverter))] +public enum EventOutputCadence { Annual, SemiAnnual, @@ -9040,10 +8682,9 @@ public enum PercentCadence Custom, } -sealed class PercentCadenceConverter - : JsonConverter +sealed class EventOutputCadenceConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.PercentCadence Read( + public override EventOutputCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9051,19 +8692,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Subscriptions.PercentCadence.Annual, - "semi_annual" => global::Orb.Models.Subscriptions.PercentCadence.SemiAnnual, - "monthly" => global::Orb.Models.Subscriptions.PercentCadence.Monthly, - "quarterly" => global::Orb.Models.Subscriptions.PercentCadence.Quarterly, - "one_time" => global::Orb.Models.Subscriptions.PercentCadence.OneTime, - "custom" => global::Orb.Models.Subscriptions.PercentCadence.Custom, - _ => (global::Orb.Models.Subscriptions.PercentCadence)(-1), + "annual" => EventOutputCadence.Annual, + "semi_annual" => EventOutputCadence.SemiAnnual, + "monthly" => EventOutputCadence.Monthly, + "quarterly" => EventOutputCadence.Quarterly, + "one_time" => EventOutputCadence.OneTime, + "custom" => EventOutputCadence.Custom, + _ => (EventOutputCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.PercentCadence value, + EventOutputCadence value, JsonSerializerOptions options ) { @@ -9071,12 +8712,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Subscriptions.PercentCadence.Annual => "annual", - global::Orb.Models.Subscriptions.PercentCadence.SemiAnnual => "semi_annual", - global::Orb.Models.Subscriptions.PercentCadence.Monthly => "monthly", - global::Orb.Models.Subscriptions.PercentCadence.Quarterly => "quarterly", - global::Orb.Models.Subscriptions.PercentCadence.OneTime => "one_time", - global::Orb.Models.Subscriptions.PercentCadence.Custom => "custom", + EventOutputCadence.Annual => "annual", + EventOutputCadence.SemiAnnual => "semi_annual", + EventOutputCadence.Monthly => "monthly", + EventOutputCadence.Quarterly => "quarterly", + EventOutputCadence.OneTime => "one_time", + EventOutputCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -9087,55 +8728,81 @@ JsonSerializerOptions options } /// -/// Configuration for percent pricing +/// Configuration for event_output pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.PercentConfig, - global::Orb.Models.Subscriptions.PercentConfigFromRaw - >) -)] -public sealed record class PercentConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class EventOutputConfig : JsonModel { /// - /// What percent of the component subtotals to charge + /// The key in the event data to extract the unit rate from. /// - public required double Percent + public required string UnitRatingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("percent"); + return this._rawData.GetNotNullClass("unit_rating_key"); } - init { this._rawData.Set("percent", value); } + init { this._rawData.Set("unit_rating_key", value); } + } + + /// + /// If provided, this amount will be used as the unit rate when an event does + /// not have a value for the `unit_rating_key`. If not provided, events missing + /// a unit rate will be ignored. + /// + public string? DefaultUnitRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("default_unit_rate"); + } + init { this._rawData.Set("default_unit_rate", value); } + } + + /// + /// An optional key in the event data to group by (e.g., event ID). All events + /// will also be grouped by their unit rate. + /// + public string? GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } } /// public override void Validate() { - _ = this.Percent; + _ = this.UnitRatingKey; + _ = this.DefaultUnitRate; + _ = this.GroupingKey; } - public PercentConfig() { } + public EventOutputConfig() { } - public PercentConfig(global::Orb.Models.Subscriptions.PercentConfig percentConfig) - : base(percentConfig) { } + public EventOutputConfig(EventOutputConfig eventOutputConfig) + : base(eventOutputConfig) { } - public PercentConfig(IReadOnlyDictionary rawData) + public EventOutputConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - PercentConfig(FrozenDictionary rawData) + EventOutputConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.PercentConfig FromRawUnchecked( + /// + public static EventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9143,23 +8810,22 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public PercentConfig(double percent) + public EventOutputConfig(string unitRatingKey) : this() { - this.Percent = percent; + this.UnitRatingKey = unitRatingKey; } } -class PercentConfigFromRaw : IFromRawJson +class EventOutputConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.PercentConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.PercentConfig.FromRawUnchecked(rawData); + public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutputConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Subscriptions.PercentConversionRateConfigConverter))] -public record class PercentConversionRateConfig : ModelBase +[JsonConverter(typeof(EventOutputConversionRateConfigConverter))] +public record class EventOutputConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -9176,7 +8842,7 @@ public JsonElement Json } } - public PercentConversionRateConfig( + public EventOutputConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -9185,7 +8851,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig( + public EventOutputConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -9194,7 +8860,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig(JsonElement element) + public EventOutputConversionRateConfig(JsonElement element) { this._element = element; } @@ -9276,7 +8942,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" + "Data did not match any variant of EventOutputConversionRateConfig" ); } } @@ -9312,16 +8978,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" + "Data did not match any variant of EventOutputConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Subscriptions.PercentConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.PercentConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -9340,13 +9006,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" + "Data did not match any variant of EventOutputConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Subscriptions.PercentConversionRateConfig? other) + public virtual bool Equals(EventOutputConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -9360,10 +9026,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class PercentConversionRateConfigConverter - : JsonConverter +sealed class EventOutputConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Subscriptions.PercentConversionRateConfig? Read( + public override EventOutputConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9428,14 +9094,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.PercentConversionRateConfig(element); + return new EventOutputConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.PercentConversionRateConfig value, + EventOutputConversionRateConfig value, JsonSerializerOptions options ) { @@ -9443,329 +9109,241 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.EventOutput, - global::Orb.Models.Subscriptions.EventOutputFromRaw - >) -)] -public sealed record class EventOutput : JsonModel +[System::Obsolete("deprecated")] +[JsonConverter(typeof(ExternalMarketplaceConverter))] +public enum ExternalMarketplace { - /// - /// The cadence to bill for this price on. - /// - public required ApiEnum Cadence + Google, + Aws, + Azure, +} + +sealed class ExternalMarketplaceConverter : JsonConverter +{ + public override ExternalMarketplace Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) { - get + return JsonSerializer.Deserialize(ref reader, options) switch { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); - } - init { this._rawData.Set("cadence", value); } + "google" => ExternalMarketplace.Google, + "aws" => ExternalMarketplace.Aws, + "azure" => ExternalMarketplace.Azure, + _ => (ExternalMarketplace)(-1), + }; } - /// - /// Configuration for event_output pricing - /// - public required global::Orb.Models.Subscriptions.EventOutputConfig EventOutputConfig + public override void Write( + Utf8JsonWriter writer, + ExternalMarketplace value, + JsonSerializerOptions options + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "event_output_config" - ); - } - init { this._rawData.Set("event_output_config", value); } + JsonSerializer.Serialize( + writer, + value switch + { + ExternalMarketplace.Google => "google", + ExternalMarketplace.Aws => "aws", + ExternalMarketplace.Azure => "azure", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); } +} +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class RemoveAdjustment : JsonModel +{ /// - /// The id of the item the price will be associated with. + /// The id of the adjustment to remove on the subscription. /// - public required string ItemID + public required string AdjustmentID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass("adjustment_id"); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("adjustment_id", value); } } - /// - /// The pricing model type - /// - public JsonElement ModelType + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); - } - init { this._rawData.Set("model_type", value); } + _ = this.AdjustmentID; } - /// - /// The name of the price. - /// - public required string Name + public RemoveAdjustment() { } + + public RemoveAdjustment(RemoveAdjustment removeAdjustment) + : base(removeAdjustment) { } + + public RemoveAdjustment(IReadOnlyDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } + this._rawData = new(rawData); } - /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. - /// - public string? BillableMetricID +#pragma warning disable CS8618 + [SetsRequiredMembers] + RemoveAdjustment(FrozenDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); - } - init { this._rawData.Set("billable_metric_id", value); } + this._rawData = new(rawData); } +#pragma warning restore CS8618 - /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. - /// - public bool? BilledInAdvance + /// + public static RemoveAdjustment FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); - } - init { this._rawData.Set("billed_in_advance", value); } + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration + [SetsRequiredMembers] + public RemoveAdjustment(string adjustmentID) + : this() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } + this.AdjustmentID = adjustmentID; } +} + +class RemoveAdjustmentFromRaw : IFromRawJson +{ + /// + public RemoveAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => + RemoveAdjustment.FromRawUnchecked(rawData); +} +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class RemovePrice : JsonModel +{ /// - /// The per unit conversion rate of the price currency to the invoicing currency. + /// The external price id of the price to remove on the subscription. /// - public double? ConversionRate + public string? ExternalPriceID { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); + return this._rawData.GetNullableClass("external_price_id"); } - init { this._rawData.Set("conversion_rate", value); } + init { this._rawData.Set("external_price_id", value); } } /// - /// The configuration for the rate of the price currency to the invoicing currency. + /// The id of the price to remove on the subscription. /// - public global::Orb.Models.Subscriptions.EventOutputConversionRateConfig? ConversionRateConfig + public string? PriceID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); + return this._rawData.GetNullableClass("price_id"); } - init { this._rawData.Set("conversion_rate_config", value); } + init { this._rawData.Set("price_id", value); } } - /// - /// An ISO 4217 currency string, or custom pricing unit identifier, in which - /// this price is billed. - /// - public string? Currency + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("currency"); - } - init { this._rawData.Set("currency", value); } + _ = this.ExternalPriceID; + _ = this.PriceID; } - /// - /// For dimensional price: specifies a price group and dimension values - /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + public RemovePrice() { } + + public RemovePrice(RemovePrice removePrice) + : base(removePrice) { } + + public RemovePrice(IReadOnlyDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + RemovePrice(FrozenDictionary rawData) + { + this._rawData = new(rawData); } +#pragma warning restore CS8618 + + /// + public static RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} +class RemovePriceFromRaw : IFromRawJson +{ + /// + public RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) => + RemovePrice.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ReplaceAdjustment : JsonModel +{ /// - /// An alias for the price. + /// The definition of a new adjustment to create and add to the subscription. /// - public string? ExternalPriceID + public required ReplaceAdjustmentAdjustment Adjustment { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); + return this._rawData.GetNotNullClass("adjustment"); } - init { this._rawData.Set("external_price_id", value); } + init { this._rawData.Set("adjustment", value); } } /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// The id of the adjustment on the plan to replace in the subscription. /// - public double? FixedPriceQuantity + public required string ReplacesAdjustmentID { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); + return this._rawData.GetNotNullClass("replaces_adjustment_id"); } - init { this._rawData.Set("fixed_price_quantity", value); } - } - - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", value); } - } - - /// - /// Within each billing cycle, specifies the cadence at which invoices are produced. - /// If unspecified, a single invoice is produced per billing cycle. - /// - public NewBillingCycleConfiguration? InvoicingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); - } - init { this._rawData.Set("invoicing_cycle_configuration", value); } - } - - /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared - /// by setting `metadata` to `null`. - /// - public IReadOnlyDictionary? Metadata - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) - ); - } - } - - /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. - /// - public string? ReferenceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("reference_id"); - } - init { this._rawData.Set("reference_id", value); } + init { this._rawData.Set("replaces_adjustment_id", value); } } /// public override void Validate() { - this.Cadence.Validate(); - this.EventOutputConfig.Validate(); - _ = this.ItemID; - if ( - !JsonElement.DeepEquals( - this.ModelType, - JsonSerializer.SerializeToElement("event_output") - ) - ) - { - throw new OrbInvalidDataException("Invalid value given for constant"); - } - _ = this.Name; - _ = this.BillableMetricID; - _ = this.BilledInAdvance; - this.BillingCycleConfiguration?.Validate(); - _ = this.ConversionRate; - this.ConversionRateConfig?.Validate(); - _ = this.Currency; - this.DimensionalPriceConfiguration?.Validate(); - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.InvoiceGroupingKey; - this.InvoicingCycleConfiguration?.Validate(); - _ = this.Metadata; - _ = this.ReferenceID; + this.Adjustment.Validate(); + _ = this.ReplacesAdjustmentID; } - public EventOutput() - { - this.ModelType = JsonSerializer.SerializeToElement("event_output"); - } + public ReplaceAdjustment() { } - public EventOutput(global::Orb.Models.Subscriptions.EventOutput eventOutput) - : base(eventOutput) { } + public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) + : base(replaceAdjustment) { } - public EventOutput(IReadOnlyDictionary rawData) + public ReplaceAdjustment(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("event_output"); } #pragma warning disable CS8618 [SetsRequiredMembers] - EventOutput(FrozenDictionary rawData) + ReplaceAdjustment(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.EventOutput FromRawUnchecked( + /// + public static ReplaceAdjustment FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9773,257 +9351,199 @@ IReadOnlyDictionary rawData } } -class EventOutputFromRaw : IFromRawJson +class ReplaceAdjustmentFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.EventOutput FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.EventOutput.FromRawUnchecked(rawData); + public ReplaceAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => + ReplaceAdjustment.FromRawUnchecked(rawData); } /// -/// The cadence to bill for this price on. +/// The definition of a new adjustment to create and add to the subscription. /// -[JsonConverter(typeof(global::Orb.Models.Subscriptions.EventOutputCadenceConverter))] -public enum EventOutputCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class EventOutputCadenceConverter - : JsonConverter +[JsonConverter(typeof(ReplaceAdjustmentAdjustmentConverter))] +public record class ReplaceAdjustmentAdjustment : ModelBase { - public override global::Orb.Models.Subscriptions.EventOutputCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => global::Orb.Models.Subscriptions.EventOutputCadence.Annual, - "semi_annual" => global::Orb.Models.Subscriptions.EventOutputCadence.SemiAnnual, - "monthly" => global::Orb.Models.Subscriptions.EventOutputCadence.Monthly, - "quarterly" => global::Orb.Models.Subscriptions.EventOutputCadence.Quarterly, - "one_time" => global::Orb.Models.Subscriptions.EventOutputCadence.OneTime, - "custom" => global::Orb.Models.Subscriptions.EventOutputCadence.Custom, - _ => (global::Orb.Models.Subscriptions.EventOutputCadence)(-1), - }; - } + public object? Value { get; } = null; - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.EventOutputCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - global::Orb.Models.Subscriptions.EventOutputCadence.Annual => "annual", - global::Orb.Models.Subscriptions.EventOutputCadence.SemiAnnual => "semi_annual", - global::Orb.Models.Subscriptions.EventOutputCadence.Monthly => "monthly", - global::Orb.Models.Subscriptions.EventOutputCadence.Quarterly => "quarterly", - global::Orb.Models.Subscriptions.EventOutputCadence.OneTime => "one_time", - global::Orb.Models.Subscriptions.EventOutputCadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} + JsonElement? _element = null; -/// -/// Configuration for event_output pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.EventOutputConfig, - global::Orb.Models.Subscriptions.EventOutputConfigFromRaw - >) -)] -public sealed record class EventOutputConfig : JsonModel -{ - /// - /// The key in the event data to extract the unit rate from. - /// - public required string UnitRatingKey + public JsonElement Json { get { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_rating_key"); + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); } - init { this._rawData.Set("unit_rating_key", value); } } - /// - /// If provided, this amount will be used as the unit rate when an event does - /// not have a value for the `unit_rating_key`. If not provided, events missing - /// a unit rate will be ignored. - /// - public string? DefaultUnitRate + public string? Currency { get { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("default_unit_rate"); + return Match( + newPercentageDiscount: (x) => x.Currency, + newUsageDiscount: (x) => x.Currency, + newAmountDiscount: (x) => x.Currency, + newMinimum: (x) => x.Currency, + newMaximum: (x) => x.Currency + ); } - init { this._rawData.Set("default_unit_rate", value); } } - /// - /// An optional key in the event data to group by (e.g., event ID). All events - /// will also be grouped by their unit rate. - /// - public string? GroupingKey + public bool? IsInvoiceLevel { get { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("grouping_key"); + return Match( + newPercentageDiscount: (x) => x.IsInvoiceLevel, + newUsageDiscount: (x) => x.IsInvoiceLevel, + newAmountDiscount: (x) => x.IsInvoiceLevel, + newMinimum: (x) => x.IsInvoiceLevel, + newMaximum: (x) => x.IsInvoiceLevel + ); } - init { this._rawData.Set("grouping_key", value); } } - /// - public override void Validate() + public ReplaceAdjustmentAdjustment(NewPercentageDiscount value, JsonElement? element = null) { - _ = this.UnitRatingKey; - _ = this.DefaultUnitRate; - _ = this.GroupingKey; + this.Value = value; + this._element = element; } - public EventOutputConfig() { } - - public EventOutputConfig(global::Orb.Models.Subscriptions.EventOutputConfig eventOutputConfig) - : base(eventOutputConfig) { } + public ReplaceAdjustmentAdjustment(NewUsageDiscount value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - public EventOutputConfig(IReadOnlyDictionary rawData) + public ReplaceAdjustmentAdjustment(NewAmountDiscount value, JsonElement? element = null) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - EventOutputConfig(FrozenDictionary rawData) + public ReplaceAdjustmentAdjustment(NewMinimum value, JsonElement? element = null) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.EventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + public ReplaceAdjustmentAdjustment(NewMaximum value, JsonElement? element = null) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this.Value = value; + this._element = element; } - [SetsRequiredMembers] - public EventOutputConfig(string unitRatingKey) - : this() + public ReplaceAdjustmentAdjustment(JsonElement element) { - this.UnitRatingKey = unitRatingKey; + this._element = element; } -} -class EventOutputConfigFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Subscriptions.EventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.EventOutputConfig.FromRawUnchecked(rawData); -} - -[JsonConverter(typeof(global::Orb.Models.Subscriptions.EventOutputConversionRateConfigConverter))] -public record class EventOutputConversionRateConfig : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - - public JsonElement Json - { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } - } - - public EventOutputConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPercentageDiscount(out var value)) { + /// // `value` is of type `NewPercentageDiscount` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) { - this.Value = value; - this._element = element; + value = this.Value as NewPercentageDiscount; + return value != null; } - public EventOutputConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewUsageDiscount(out var value)) { + /// // `value` is of type `NewUsageDiscount` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) { - this.Value = value; - this._element = element; + value = this.Value as NewUsageDiscount; + return value != null; } - public EventOutputConversionRateConfig(JsonElement element) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewAmountDiscount(out var value)) { + /// // `value` is of type `NewAmountDiscount` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) { - this._element = element; + value = this.Value as NewAmountDiscount; + return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` + /// if (instance.TryPickNewMinimum(out var value)) { + /// // `value` is of type `NewMinimum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? value) { - value = this.Value as SharedUnitConversionRateConfig; + value = this.Value as NewMinimum; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` + /// if (instance.TryPickNewMaximum(out var value)) { + /// // `value` is of type `NewMaximum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) { - value = this.Value as SharedTieredConversionRateConfig; + value = this.Value as NewMaximum; return value != null; } @@ -10041,28 +9561,43 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// /// public void Switch( - System::Action unit, - System::Action tiered + System::Action newPercentageDiscount, + System::Action newUsageDiscount, + System::Action newAmountDiscount, + System::Action newMinimum, + System::Action newMaximum ) { switch (this.Value) { - case SharedUnitConversionRateConfig value: - unit(value); + case NewPercentageDiscount value: + newPercentageDiscount(value); break; - case SharedTieredConversionRateConfig value: - tiered(value); + case NewUsageDiscount value: + newUsageDiscount(value); + break; + case NewAmountDiscount value: + newAmountDiscount(value); + break; + case NewMinimum value: + newMinimum(value); + break; + case NewMaximum value: + newMaximum(value); break; default: throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + "Data did not match any variant of ReplaceAdjustmentAdjustment" ); } } @@ -10082,34 +9617,48 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// /// public T Match( - System::Func unit, - System::Func tiered + System::Func newPercentageDiscount, + System::Func newUsageDiscount, + System::Func newAmountDiscount, + System::Func newMinimum, + System::Func newMaximum ) { return this.Value switch { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), + NewPercentageDiscount value => newPercentageDiscount(value), + NewUsageDiscount value => newUsageDiscount(value), + NewAmountDiscount value => newAmountDiscount(value), + NewMinimum value => newMinimum(value), + NewMaximum value => newMaximum(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + "Data did not match any variant of ReplaceAdjustmentAdjustment" ), }; } - public static implicit operator global::Orb.Models.Subscriptions.EventOutputConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); + public static implicit operator ReplaceAdjustmentAdjustment(NewPercentageDiscount value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.EventOutputConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); + public static implicit operator ReplaceAdjustmentAdjustment(NewUsageDiscount value) => + new(value); + + public static implicit operator ReplaceAdjustmentAdjustment(NewAmountDiscount value) => + new(value); + + public static implicit operator ReplaceAdjustmentAdjustment(NewMinimum value) => new(value); + + public static implicit operator ReplaceAdjustmentAdjustment(NewMaximum value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -10126,15 +9675,19 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + "Data did not match any variant of ReplaceAdjustmentAdjustment" ); } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + this.Switch( + (newPercentageDiscount) => newPercentageDiscount.Validate(), + (newUsageDiscount) => newUsageDiscount.Validate(), + (newAmountDiscount) => newAmountDiscount.Validate(), + (newMinimum) => newMinimum.Validate(), + (newMaximum) => newMaximum.Validate() + ); } - public virtual bool Equals( - global::Orb.Models.Subscriptions.EventOutputConversionRateConfig? other - ) + public virtual bool Equals(ReplaceAdjustmentAdjustment? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -10148,33 +9701,32 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class EventOutputConversionRateConfigConverter - : JsonConverter +sealed class ReplaceAdjustmentAdjustmentConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.EventOutputConversionRateConfig? Read( + public override ReplaceAdjustmentAdjustment? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options ) { var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; + string? adjustmentType; try { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); + adjustmentType = element.GetProperty("adjustment_type").GetString(); } catch { - conversionRateType = null; + adjustmentType = null; } - switch (conversionRateType) + switch (adjustmentType) { - case "unit": + case "percentage_discount": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -10192,11 +9744,11 @@ JsonSerializerOptions options return new(element); } - case "tiered": + case "usage_discount": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -10214,154 +9766,204 @@ JsonSerializerOptions options return new(element); } - default: + case "amount_discount": { - return new global::Orb.Models.Subscriptions.EventOutputConversionRateConfig( - element - ); + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } + + return new(element); } - } - } + case "minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.EventOutputConversionRateConfig value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } -} - -[System::Obsolete("deprecated")] -[JsonConverter(typeof(ExternalMarketplaceConverter))] -public enum ExternalMarketplace -{ - Google, - Aws, - Azure, -} + return new(element); + } + case "maximum": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -sealed class ExternalMarketplaceConverter : JsonConverter -{ - public override ExternalMarketplace Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "google" => ExternalMarketplace.Google, - "aws" => ExternalMarketplace.Aws, - "azure" => ExternalMarketplace.Azure, - _ => (ExternalMarketplace)(-1), - }; + return new(element); + } + default: + { + return new ReplaceAdjustmentAdjustment(element); + } + } } public override void Write( Utf8JsonWriter writer, - ExternalMarketplace value, + ReplaceAdjustmentAdjustment value, JsonSerializerOptions options ) { - JsonSerializer.Serialize( - writer, - value switch - { - ExternalMarketplace.Google => "google", - ExternalMarketplace.Aws => "aws", - ExternalMarketplace.Azure => "azure", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); + JsonSerializer.Serialize(writer, value.Json, options); } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class RemoveAdjustment : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ReplacePrice : JsonModel { /// - /// The id of the adjustment to remove on the subscription. + /// The id of the price on the plan to replace in the subscription. /// - public required string AdjustmentID + public required string ReplacesPriceID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment_id"); + return this._rawData.GetNotNullClass("replaces_price_id"); } - init { this._rawData.Set("adjustment_id", value); } + init { this._rawData.Set("replaces_price_id", value); } } - /// - public override void Validate() + /// + /// The definition of a new allocation price to create and add to the subscription. + /// + public NewAllocationPrice? AllocationPrice { - _ = this.AdjustmentID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("allocation_price"); + } + init { this._rawData.Set("allocation_price", value); } } - public RemoveAdjustment() { } - - public RemoveAdjustment(RemoveAdjustment removeAdjustment) - : base(removeAdjustment) { } - - public RemoveAdjustment(IReadOnlyDictionary rawData) + /// + /// [DEPRECATED] Use add_adjustments instead. The subscription's discounts for + /// the replacement price. + /// + [System::Obsolete("deprecated")] + public IReadOnlyList? Discounts { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("discounts"); + } + init + { + this._rawData.Set?>( + "discounts", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } } -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemoveAdjustment(FrozenDictionary rawData) + /// + /// The external price id of the price to add to the subscription. + /// + public string? ExternalPriceID { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } } -#pragma warning restore CS8618 - /// - public static RemoveAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + /// The new quantity of the price, if the price is a fixed price. + /// + public double? FixedPriceQuantity { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } } - [SetsRequiredMembers] - public RemoveAdjustment(string adjustmentID) - : this() + /// + /// [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount + /// for the replacement price. + /// + [System::Obsolete("deprecated")] + public string? MaximumAmount { - this.AdjustmentID = adjustmentID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("maximum_amount"); + } + init { this._rawData.Set("maximum_amount", value); } } -} -class RemoveAdjustmentFromRaw : IFromRawJson -{ - /// - public RemoveAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => - RemoveAdjustment.FromRawUnchecked(rawData); -} + /// + /// [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount + /// for the replacement price. + /// + [System::Obsolete("deprecated")] + public string? MinimumAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("minimum_amount"); + } + init { this._rawData.Set("minimum_amount", value); } + } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class RemovePrice : JsonModel -{ /// - /// The external price id of the price to remove on the subscription. + /// New subscription price request body params. /// - public string? ExternalPriceID + public ReplacePricePrice? Price { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); + return this._rawData.GetNullableClass("price"); } - init { this._rawData.Set("external_price_id", value); } + init { this._rawData.Set("price", value); } } /// - /// The id of the price to remove on the subscription. + /// The id of the price to add to the subscription. /// public string? PriceID { @@ -10376,4566 +9978,2797 @@ public string? PriceID /// public override void Validate() { + _ = this.ReplacesPriceID; + this.AllocationPrice?.Validate(); + foreach (var item in this.Discounts ?? []) + { + item.Validate(); + } _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.MaximumAmount; + _ = this.MinimumAmount; + this.Price?.Validate(); _ = this.PriceID; } - public RemovePrice() { } + public ReplacePrice() { } - public RemovePrice(RemovePrice removePrice) - : base(removePrice) { } + public ReplacePrice(ReplacePrice replacePrice) + : base(replacePrice) { } - public RemovePrice(IReadOnlyDictionary rawData) + public ReplacePrice(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - RemovePrice(FrozenDictionary rawData) + ReplacePrice(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } + + [SetsRequiredMembers] + public ReplacePrice(string replacesPriceID) + : this() + { + this.ReplacesPriceID = replacesPriceID; + } } -class RemovePriceFromRaw : IFromRawJson +class ReplacePriceFromRaw : IFromRawJson { /// - public RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) => - RemovePrice.FromRawUnchecked(rawData); + public ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) => + ReplacePrice.FromRawUnchecked(rawData); } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class ReplaceAdjustment : JsonModel +/// +/// New subscription price request body params. +/// +[JsonConverter(typeof(ReplacePricePriceConverter))] +public record class ReplacePricePrice : ModelBase { - /// - /// The definition of a new adjustment to create and add to the subscription. - /// - public required ReplaceAdjustmentAdjustment Adjustment + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json { get { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment"); + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); } - init { this._rawData.Set("adjustment", value); } } - /// - /// The id of the adjustment on the plan to replace in the subscription. - /// - public required string ReplacesAdjustmentID + public string ItemID { get { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_adjustment_id"); + return Match( + newSubscriptionUnit: (x) => x.ItemID, + newSubscriptionTiered: (x) => x.ItemID, + newSubscriptionBulk: (x) => x.ItemID, + bulkWithFilters: (x) => x.ItemID, + newSubscriptionPackage: (x) => x.ItemID, + newSubscriptionMatrix: (x) => x.ItemID, + newSubscriptionThresholdTotalAmount: (x) => x.ItemID, + newSubscriptionTieredPackage: (x) => x.ItemID, + newSubscriptionTieredWithMinimum: (x) => x.ItemID, + newSubscriptionGroupedTiered: (x) => x.ItemID, + newSubscriptionTieredPackageWithMinimum: (x) => x.ItemID, + newSubscriptionPackageWithAllocation: (x) => x.ItemID, + newSubscriptionUnitWithPercent: (x) => x.ItemID, + newSubscriptionMatrixWithAllocation: (x) => x.ItemID, + tieredWithProration: (x) => x.ItemID, + newSubscriptionUnitWithProration: (x) => x.ItemID, + newSubscriptionGroupedAllocation: (x) => x.ItemID, + newSubscriptionBulkWithProration: (x) => x.ItemID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.ItemID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.ItemID, + groupedWithMinMaxThresholds: (x) => x.ItemID, + newSubscriptionMatrixWithDisplayName: (x) => x.ItemID, + newSubscriptionGroupedTieredPackage: (x) => x.ItemID, + newSubscriptionMaxGroupTieredPackage: (x) => x.ItemID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ItemID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ItemID, + newSubscriptionCumulativeGroupedBulk: (x) => x.ItemID, + cumulativeGroupedAllocation: (x) => x.ItemID, + newSubscriptionMinimumComposite: (x) => x.ItemID, + percent: (x) => x.ItemID, + eventOutput: (x) => x.ItemID + ); } - init { this._rawData.Set("replaces_adjustment_id", value); } - } - - /// - public override void Validate() - { - this.Adjustment.Validate(); - _ = this.ReplacesAdjustmentID; - } - - public ReplaceAdjustment() { } - - public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) - : base(replaceAdjustment) { } - - public ReplaceAdjustment(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplaceAdjustment(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static ReplaceAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); } -} - -class ReplaceAdjustmentFromRaw : IFromRawJson -{ - /// - public ReplaceAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => - ReplaceAdjustment.FromRawUnchecked(rawData); -} - -/// -/// The definition of a new adjustment to create and add to the subscription. -/// -[JsonConverter(typeof(ReplaceAdjustmentAdjustmentConverter))] -public record class ReplaceAdjustmentAdjustment : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - public JsonElement Json + public string Name { get { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions + return Match( + newSubscriptionUnit: (x) => x.Name, + newSubscriptionTiered: (x) => x.Name, + newSubscriptionBulk: (x) => x.Name, + bulkWithFilters: (x) => x.Name, + newSubscriptionPackage: (x) => x.Name, + newSubscriptionMatrix: (x) => x.Name, + newSubscriptionThresholdTotalAmount: (x) => x.Name, + newSubscriptionTieredPackage: (x) => x.Name, + newSubscriptionTieredWithMinimum: (x) => x.Name, + newSubscriptionGroupedTiered: (x) => x.Name, + newSubscriptionTieredPackageWithMinimum: (x) => x.Name, + newSubscriptionPackageWithAllocation: (x) => x.Name, + newSubscriptionUnitWithPercent: (x) => x.Name, + newSubscriptionMatrixWithAllocation: (x) => x.Name, + tieredWithProration: (x) => x.Name, + newSubscriptionUnitWithProration: (x) => x.Name, + newSubscriptionGroupedAllocation: (x) => x.Name, + newSubscriptionBulkWithProration: (x) => x.Name, + newSubscriptionGroupedWithProratedMinimum: (x) => x.Name, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.Name, + groupedWithMinMaxThresholds: (x) => x.Name, + newSubscriptionMatrixWithDisplayName: (x) => x.Name, + newSubscriptionGroupedTieredPackage: (x) => x.Name, + newSubscriptionMaxGroupTieredPackage: (x) => x.Name, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.Name, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Name, + newSubscriptionCumulativeGroupedBulk: (x) => x.Name, + cumulativeGroupedAllocation: (x) => x.Name, + newSubscriptionMinimumComposite: (x) => x.Name, + percent: (x) => x.Name, + eventOutput: (x) => x.Name ); } } - public string? Currency + public string? BillableMetricID { get { return Match( - newPercentageDiscount: (x) => x.Currency, - newUsageDiscount: (x) => x.Currency, - newAmountDiscount: (x) => x.Currency, - newMinimum: (x) => x.Currency, - newMaximum: (x) => x.Currency + newSubscriptionUnit: (x) => x.BillableMetricID, + newSubscriptionTiered: (x) => x.BillableMetricID, + newSubscriptionBulk: (x) => x.BillableMetricID, + bulkWithFilters: (x) => x.BillableMetricID, + newSubscriptionPackage: (x) => x.BillableMetricID, + newSubscriptionMatrix: (x) => x.BillableMetricID, + newSubscriptionThresholdTotalAmount: (x) => x.BillableMetricID, + newSubscriptionTieredPackage: (x) => x.BillableMetricID, + newSubscriptionTieredWithMinimum: (x) => x.BillableMetricID, + newSubscriptionGroupedTiered: (x) => x.BillableMetricID, + newSubscriptionTieredPackageWithMinimum: (x) => x.BillableMetricID, + newSubscriptionPackageWithAllocation: (x) => x.BillableMetricID, + newSubscriptionUnitWithPercent: (x) => x.BillableMetricID, + newSubscriptionMatrixWithAllocation: (x) => x.BillableMetricID, + tieredWithProration: (x) => x.BillableMetricID, + newSubscriptionUnitWithProration: (x) => x.BillableMetricID, + newSubscriptionGroupedAllocation: (x) => x.BillableMetricID, + newSubscriptionBulkWithProration: (x) => x.BillableMetricID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.BillableMetricID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.BillableMetricID, + groupedWithMinMaxThresholds: (x) => x.BillableMetricID, + newSubscriptionMatrixWithDisplayName: (x) => x.BillableMetricID, + newSubscriptionGroupedTieredPackage: (x) => x.BillableMetricID, + newSubscriptionMaxGroupTieredPackage: (x) => x.BillableMetricID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BillableMetricID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, + newSubscriptionCumulativeGroupedBulk: (x) => x.BillableMetricID, + cumulativeGroupedAllocation: (x) => x.BillableMetricID, + newSubscriptionMinimumComposite: (x) => x.BillableMetricID, + percent: (x) => x.BillableMetricID, + eventOutput: (x) => x.BillableMetricID ); } } - public bool? IsInvoiceLevel + public bool? BilledInAdvance { get { return Match( - newPercentageDiscount: (x) => x.IsInvoiceLevel, - newUsageDiscount: (x) => x.IsInvoiceLevel, - newAmountDiscount: (x) => x.IsInvoiceLevel, - newMinimum: (x) => x.IsInvoiceLevel, - newMaximum: (x) => x.IsInvoiceLevel + newSubscriptionUnit: (x) => x.BilledInAdvance, + newSubscriptionTiered: (x) => x.BilledInAdvance, + newSubscriptionBulk: (x) => x.BilledInAdvance, + bulkWithFilters: (x) => x.BilledInAdvance, + newSubscriptionPackage: (x) => x.BilledInAdvance, + newSubscriptionMatrix: (x) => x.BilledInAdvance, + newSubscriptionThresholdTotalAmount: (x) => x.BilledInAdvance, + newSubscriptionTieredPackage: (x) => x.BilledInAdvance, + newSubscriptionTieredWithMinimum: (x) => x.BilledInAdvance, + newSubscriptionGroupedTiered: (x) => x.BilledInAdvance, + newSubscriptionTieredPackageWithMinimum: (x) => x.BilledInAdvance, + newSubscriptionPackageWithAllocation: (x) => x.BilledInAdvance, + newSubscriptionUnitWithPercent: (x) => x.BilledInAdvance, + newSubscriptionMatrixWithAllocation: (x) => x.BilledInAdvance, + tieredWithProration: (x) => x.BilledInAdvance, + newSubscriptionUnitWithProration: (x) => x.BilledInAdvance, + newSubscriptionGroupedAllocation: (x) => x.BilledInAdvance, + newSubscriptionBulkWithProration: (x) => x.BilledInAdvance, + newSubscriptionGroupedWithProratedMinimum: (x) => x.BilledInAdvance, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.BilledInAdvance, + groupedWithMinMaxThresholds: (x) => x.BilledInAdvance, + newSubscriptionMatrixWithDisplayName: (x) => x.BilledInAdvance, + newSubscriptionGroupedTieredPackage: (x) => x.BilledInAdvance, + newSubscriptionMaxGroupTieredPackage: (x) => x.BilledInAdvance, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BilledInAdvance, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, + newSubscriptionCumulativeGroupedBulk: (x) => x.BilledInAdvance, + cumulativeGroupedAllocation: (x) => x.BilledInAdvance, + newSubscriptionMinimumComposite: (x) => x.BilledInAdvance, + percent: (x) => x.BilledInAdvance, + eventOutput: (x) => x.BilledInAdvance ); } } - public ReplaceAdjustmentAdjustment(NewPercentageDiscount value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplaceAdjustmentAdjustment(NewUsageDiscount value, JsonElement? element = null) + public NewBillingCycleConfiguration? BillingCycleConfiguration { - this.Value = value; - this._element = element; + get + { + return Match( + newSubscriptionUnit: (x) => x.BillingCycleConfiguration, + newSubscriptionTiered: (x) => x.BillingCycleConfiguration, + newSubscriptionBulk: (x) => x.BillingCycleConfiguration, + bulkWithFilters: (x) => x.BillingCycleConfiguration, + newSubscriptionPackage: (x) => x.BillingCycleConfiguration, + newSubscriptionMatrix: (x) => x.BillingCycleConfiguration, + newSubscriptionThresholdTotalAmount: (x) => x.BillingCycleConfiguration, + newSubscriptionTieredPackage: (x) => x.BillingCycleConfiguration, + newSubscriptionTieredWithMinimum: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedTiered: (x) => x.BillingCycleConfiguration, + newSubscriptionTieredPackageWithMinimum: (x) => x.BillingCycleConfiguration, + newSubscriptionPackageWithAllocation: (x) => x.BillingCycleConfiguration, + newSubscriptionUnitWithPercent: (x) => x.BillingCycleConfiguration, + newSubscriptionMatrixWithAllocation: (x) => x.BillingCycleConfiguration, + tieredWithProration: (x) => x.BillingCycleConfiguration, + newSubscriptionUnitWithProration: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedAllocation: (x) => x.BillingCycleConfiguration, + newSubscriptionBulkWithProration: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedWithProratedMinimum: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.BillingCycleConfiguration, + groupedWithMinMaxThresholds: (x) => x.BillingCycleConfiguration, + newSubscriptionMatrixWithDisplayName: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedTieredPackage: (x) => x.BillingCycleConfiguration, + newSubscriptionMaxGroupTieredPackage: (x) => x.BillingCycleConfiguration, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BillingCycleConfiguration, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, + newSubscriptionCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, + cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, + newSubscriptionMinimumComposite: (x) => x.BillingCycleConfiguration, + percent: (x) => x.BillingCycleConfiguration, + eventOutput: (x) => x.BillingCycleConfiguration + ); + } } - public ReplaceAdjustmentAdjustment(NewAmountDiscount value, JsonElement? element = null) + public double? ConversionRate { - this.Value = value; - this._element = element; - } - - public ReplaceAdjustmentAdjustment(NewMinimum value, JsonElement? element = null) - { - this.Value = value; - this._element = element; + get + { + return Match( + newSubscriptionUnit: (x) => x.ConversionRate, + newSubscriptionTiered: (x) => x.ConversionRate, + newSubscriptionBulk: (x) => x.ConversionRate, + bulkWithFilters: (x) => x.ConversionRate, + newSubscriptionPackage: (x) => x.ConversionRate, + newSubscriptionMatrix: (x) => x.ConversionRate, + newSubscriptionThresholdTotalAmount: (x) => x.ConversionRate, + newSubscriptionTieredPackage: (x) => x.ConversionRate, + newSubscriptionTieredWithMinimum: (x) => x.ConversionRate, + newSubscriptionGroupedTiered: (x) => x.ConversionRate, + newSubscriptionTieredPackageWithMinimum: (x) => x.ConversionRate, + newSubscriptionPackageWithAllocation: (x) => x.ConversionRate, + newSubscriptionUnitWithPercent: (x) => x.ConversionRate, + newSubscriptionMatrixWithAllocation: (x) => x.ConversionRate, + tieredWithProration: (x) => x.ConversionRate, + newSubscriptionUnitWithProration: (x) => x.ConversionRate, + newSubscriptionGroupedAllocation: (x) => x.ConversionRate, + newSubscriptionBulkWithProration: (x) => x.ConversionRate, + newSubscriptionGroupedWithProratedMinimum: (x) => x.ConversionRate, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.ConversionRate, + groupedWithMinMaxThresholds: (x) => x.ConversionRate, + newSubscriptionMatrixWithDisplayName: (x) => x.ConversionRate, + newSubscriptionGroupedTieredPackage: (x) => x.ConversionRate, + newSubscriptionMaxGroupTieredPackage: (x) => x.ConversionRate, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ConversionRate, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ConversionRate, + newSubscriptionCumulativeGroupedBulk: (x) => x.ConversionRate, + cumulativeGroupedAllocation: (x) => x.ConversionRate, + newSubscriptionMinimumComposite: (x) => x.ConversionRate, + percent: (x) => x.ConversionRate, + eventOutput: (x) => x.ConversionRate + ); + } } - public ReplaceAdjustmentAdjustment(NewMaximum value, JsonElement? element = null) + public string? Currency { - this.Value = value; - this._element = element; + get + { + return Match( + newSubscriptionUnit: (x) => x.Currency, + newSubscriptionTiered: (x) => x.Currency, + newSubscriptionBulk: (x) => x.Currency, + bulkWithFilters: (x) => x.Currency, + newSubscriptionPackage: (x) => x.Currency, + newSubscriptionMatrix: (x) => x.Currency, + newSubscriptionThresholdTotalAmount: (x) => x.Currency, + newSubscriptionTieredPackage: (x) => x.Currency, + newSubscriptionTieredWithMinimum: (x) => x.Currency, + newSubscriptionGroupedTiered: (x) => x.Currency, + newSubscriptionTieredPackageWithMinimum: (x) => x.Currency, + newSubscriptionPackageWithAllocation: (x) => x.Currency, + newSubscriptionUnitWithPercent: (x) => x.Currency, + newSubscriptionMatrixWithAllocation: (x) => x.Currency, + tieredWithProration: (x) => x.Currency, + newSubscriptionUnitWithProration: (x) => x.Currency, + newSubscriptionGroupedAllocation: (x) => x.Currency, + newSubscriptionBulkWithProration: (x) => x.Currency, + newSubscriptionGroupedWithProratedMinimum: (x) => x.Currency, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.Currency, + groupedWithMinMaxThresholds: (x) => x.Currency, + newSubscriptionMatrixWithDisplayName: (x) => x.Currency, + newSubscriptionGroupedTieredPackage: (x) => x.Currency, + newSubscriptionMaxGroupTieredPackage: (x) => x.Currency, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.Currency, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Currency, + newSubscriptionCumulativeGroupedBulk: (x) => x.Currency, + cumulativeGroupedAllocation: (x) => x.Currency, + newSubscriptionMinimumComposite: (x) => x.Currency, + percent: (x) => x.Currency, + eventOutput: (x) => x.Currency + ); + } } - public ReplaceAdjustmentAdjustment(JsonElement element) + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { - this._element = element; + get + { + return Match( + newSubscriptionUnit: (x) => x.DimensionalPriceConfiguration, + newSubscriptionTiered: (x) => x.DimensionalPriceConfiguration, + newSubscriptionBulk: (x) => x.DimensionalPriceConfiguration, + bulkWithFilters: (x) => x.DimensionalPriceConfiguration, + newSubscriptionPackage: (x) => x.DimensionalPriceConfiguration, + newSubscriptionMatrix: (x) => x.DimensionalPriceConfiguration, + newSubscriptionThresholdTotalAmount: (x) => x.DimensionalPriceConfiguration, + newSubscriptionTieredPackage: (x) => x.DimensionalPriceConfiguration, + newSubscriptionTieredWithMinimum: (x) => x.DimensionalPriceConfiguration, + newSubscriptionGroupedTiered: (x) => x.DimensionalPriceConfiguration, + newSubscriptionTieredPackageWithMinimum: (x) => x.DimensionalPriceConfiguration, + newSubscriptionPackageWithAllocation: (x) => x.DimensionalPriceConfiguration, + newSubscriptionUnitWithPercent: (x) => x.DimensionalPriceConfiguration, + newSubscriptionMatrixWithAllocation: (x) => x.DimensionalPriceConfiguration, + tieredWithProration: (x) => x.DimensionalPriceConfiguration, + newSubscriptionUnitWithProration: (x) => x.DimensionalPriceConfiguration, + newSubscriptionGroupedAllocation: (x) => x.DimensionalPriceConfiguration, + newSubscriptionBulkWithProration: (x) => x.DimensionalPriceConfiguration, + newSubscriptionGroupedWithProratedMinimum: (x) => x.DimensionalPriceConfiguration, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.DimensionalPriceConfiguration, + groupedWithMinMaxThresholds: (x) => x.DimensionalPriceConfiguration, + newSubscriptionMatrixWithDisplayName: (x) => x.DimensionalPriceConfiguration, + newSubscriptionGroupedTieredPackage: (x) => x.DimensionalPriceConfiguration, + newSubscriptionMaxGroupTieredPackage: (x) => x.DimensionalPriceConfiguration, + newSubscriptionScalableMatrixWithUnitPricing: (x) => + x.DimensionalPriceConfiguration, + newSubscriptionScalableMatrixWithTieredPricing: (x) => + x.DimensionalPriceConfiguration, + newSubscriptionCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, + cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, + newSubscriptionMinimumComposite: (x) => x.DimensionalPriceConfiguration, + percent: (x) => x.DimensionalPriceConfiguration, + eventOutput: (x) => x.DimensionalPriceConfiguration + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPercentageDiscount(out var value)) { - /// // `value` is of type `NewPercentageDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) + public string? ExternalPriceID { - value = this.Value as NewPercentageDiscount; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.ExternalPriceID, + newSubscriptionTiered: (x) => x.ExternalPriceID, + newSubscriptionBulk: (x) => x.ExternalPriceID, + bulkWithFilters: (x) => x.ExternalPriceID, + newSubscriptionPackage: (x) => x.ExternalPriceID, + newSubscriptionMatrix: (x) => x.ExternalPriceID, + newSubscriptionThresholdTotalAmount: (x) => x.ExternalPriceID, + newSubscriptionTieredPackage: (x) => x.ExternalPriceID, + newSubscriptionTieredWithMinimum: (x) => x.ExternalPriceID, + newSubscriptionGroupedTiered: (x) => x.ExternalPriceID, + newSubscriptionTieredPackageWithMinimum: (x) => x.ExternalPriceID, + newSubscriptionPackageWithAllocation: (x) => x.ExternalPriceID, + newSubscriptionUnitWithPercent: (x) => x.ExternalPriceID, + newSubscriptionMatrixWithAllocation: (x) => x.ExternalPriceID, + tieredWithProration: (x) => x.ExternalPriceID, + newSubscriptionUnitWithProration: (x) => x.ExternalPriceID, + newSubscriptionGroupedAllocation: (x) => x.ExternalPriceID, + newSubscriptionBulkWithProration: (x) => x.ExternalPriceID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.ExternalPriceID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.ExternalPriceID, + groupedWithMinMaxThresholds: (x) => x.ExternalPriceID, + newSubscriptionMatrixWithDisplayName: (x) => x.ExternalPriceID, + newSubscriptionGroupedTieredPackage: (x) => x.ExternalPriceID, + newSubscriptionMaxGroupTieredPackage: (x) => x.ExternalPriceID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ExternalPriceID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, + newSubscriptionCumulativeGroupedBulk: (x) => x.ExternalPriceID, + cumulativeGroupedAllocation: (x) => x.ExternalPriceID, + newSubscriptionMinimumComposite: (x) => x.ExternalPriceID, + percent: (x) => x.ExternalPriceID, + eventOutput: (x) => x.ExternalPriceID + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewUsageDiscount(out var value)) { - /// // `value` is of type `NewUsageDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) + public double? FixedPriceQuantity { - value = this.Value as NewUsageDiscount; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.FixedPriceQuantity, + newSubscriptionTiered: (x) => x.FixedPriceQuantity, + newSubscriptionBulk: (x) => x.FixedPriceQuantity, + bulkWithFilters: (x) => x.FixedPriceQuantity, + newSubscriptionPackage: (x) => x.FixedPriceQuantity, + newSubscriptionMatrix: (x) => x.FixedPriceQuantity, + newSubscriptionThresholdTotalAmount: (x) => x.FixedPriceQuantity, + newSubscriptionTieredPackage: (x) => x.FixedPriceQuantity, + newSubscriptionTieredWithMinimum: (x) => x.FixedPriceQuantity, + newSubscriptionGroupedTiered: (x) => x.FixedPriceQuantity, + newSubscriptionTieredPackageWithMinimum: (x) => x.FixedPriceQuantity, + newSubscriptionPackageWithAllocation: (x) => x.FixedPriceQuantity, + newSubscriptionUnitWithPercent: (x) => x.FixedPriceQuantity, + newSubscriptionMatrixWithAllocation: (x) => x.FixedPriceQuantity, + tieredWithProration: (x) => x.FixedPriceQuantity, + newSubscriptionUnitWithProration: (x) => x.FixedPriceQuantity, + newSubscriptionGroupedAllocation: (x) => x.FixedPriceQuantity, + newSubscriptionBulkWithProration: (x) => x.FixedPriceQuantity, + newSubscriptionGroupedWithProratedMinimum: (x) => x.FixedPriceQuantity, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.FixedPriceQuantity, + groupedWithMinMaxThresholds: (x) => x.FixedPriceQuantity, + newSubscriptionMatrixWithDisplayName: (x) => x.FixedPriceQuantity, + newSubscriptionGroupedTieredPackage: (x) => x.FixedPriceQuantity, + newSubscriptionMaxGroupTieredPackage: (x) => x.FixedPriceQuantity, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.FixedPriceQuantity, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, + newSubscriptionCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, + cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, + newSubscriptionMinimumComposite: (x) => x.FixedPriceQuantity, + percent: (x) => x.FixedPriceQuantity, + eventOutput: (x) => x.FixedPriceQuantity + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewAmountDiscount(out var value)) { - /// // `value` is of type `NewAmountDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) + public string? InvoiceGroupingKey { - value = this.Value as NewAmountDiscount; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewMinimum(out var value)) { - /// // `value` is of type `NewMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? value) - { - value = this.Value as NewMinimum; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.InvoiceGroupingKey, + newSubscriptionTiered: (x) => x.InvoiceGroupingKey, + newSubscriptionBulk: (x) => x.InvoiceGroupingKey, + bulkWithFilters: (x) => x.InvoiceGroupingKey, + newSubscriptionPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionMatrix: (x) => x.InvoiceGroupingKey, + newSubscriptionThresholdTotalAmount: (x) => x.InvoiceGroupingKey, + newSubscriptionTieredPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionTieredWithMinimum: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedTiered: (x) => x.InvoiceGroupingKey, + newSubscriptionTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, + newSubscriptionPackageWithAllocation: (x) => x.InvoiceGroupingKey, + newSubscriptionUnitWithPercent: (x) => x.InvoiceGroupingKey, + newSubscriptionMatrixWithAllocation: (x) => x.InvoiceGroupingKey, + tieredWithProration: (x) => x.InvoiceGroupingKey, + newSubscriptionUnitWithProration: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedAllocation: (x) => x.InvoiceGroupingKey, + newSubscriptionBulkWithProration: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.InvoiceGroupingKey, + groupedWithMinMaxThresholds: (x) => x.InvoiceGroupingKey, + newSubscriptionMatrixWithDisplayName: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedTieredPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionMaxGroupTieredPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, + newSubscriptionCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, + cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, + newSubscriptionMinimumComposite: (x) => x.InvoiceGroupingKey, + percent: (x) => x.InvoiceGroupingKey, + eventOutput: (x) => x.InvoiceGroupingKey + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewMaximum(out var value)) { - /// // `value` is of type `NewMaximum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) + public NewBillingCycleConfiguration? InvoicingCycleConfiguration { - value = this.Value as NewMaximum; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTiered: (x) => x.InvoicingCycleConfiguration, + newSubscriptionBulk: (x) => x.InvoicingCycleConfiguration, + bulkWithFilters: (x) => x.InvoicingCycleConfiguration, + newSubscriptionPackage: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMatrix: (x) => x.InvoicingCycleConfiguration, + newSubscriptionThresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTieredPackage: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTieredWithMinimum: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedTiered: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, + newSubscriptionPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, + newSubscriptionUnitWithPercent: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, + tieredWithProration: (x) => x.InvoicingCycleConfiguration, + newSubscriptionUnitWithProration: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedAllocation: (x) => x.InvoicingCycleConfiguration, + newSubscriptionBulkWithProration: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedWithProratedMinimum: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.InvoicingCycleConfiguration, + groupedWithMinMaxThresholds: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMatrixWithDisplayName: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedTieredPackage: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMaxGroupTieredPackage: (x) => x.InvoicingCycleConfiguration, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.InvoicingCycleConfiguration, + newSubscriptionScalableMatrixWithTieredPricing: (x) => + x.InvoicingCycleConfiguration, + newSubscriptionCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, + cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMinimumComposite: (x) => x.InvoicingCycleConfiguration, + percent: (x) => x.InvoicingCycleConfiguration, + eventOutput: (x) => x.InvoicingCycleConfiguration + ); + } } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action newPercentageDiscount, - System::Action newUsageDiscount, - System::Action newAmountDiscount, - System::Action newMinimum, - System::Action newMaximum - ) + public string? ReferenceID { - switch (this.Value) + get { - case NewPercentageDiscount value: - newPercentageDiscount(value); - break; - case NewUsageDiscount value: - newUsageDiscount(value); - break; - case NewAmountDiscount value: - newAmountDiscount(value); - break; - case NewMinimum value: - newMinimum(value); - break; - case NewMaximum value: - newMaximum(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of ReplaceAdjustmentAdjustment" - ); + return Match( + newSubscriptionUnit: (x) => x.ReferenceID, + newSubscriptionTiered: (x) => x.ReferenceID, + newSubscriptionBulk: (x) => x.ReferenceID, + bulkWithFilters: (x) => x.ReferenceID, + newSubscriptionPackage: (x) => x.ReferenceID, + newSubscriptionMatrix: (x) => x.ReferenceID, + newSubscriptionThresholdTotalAmount: (x) => x.ReferenceID, + newSubscriptionTieredPackage: (x) => x.ReferenceID, + newSubscriptionTieredWithMinimum: (x) => x.ReferenceID, + newSubscriptionGroupedTiered: (x) => x.ReferenceID, + newSubscriptionTieredPackageWithMinimum: (x) => x.ReferenceID, + newSubscriptionPackageWithAllocation: (x) => x.ReferenceID, + newSubscriptionUnitWithPercent: (x) => x.ReferenceID, + newSubscriptionMatrixWithAllocation: (x) => x.ReferenceID, + tieredWithProration: (x) => x.ReferenceID, + newSubscriptionUnitWithProration: (x) => x.ReferenceID, + newSubscriptionGroupedAllocation: (x) => x.ReferenceID, + newSubscriptionBulkWithProration: (x) => x.ReferenceID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.ReferenceID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.ReferenceID, + groupedWithMinMaxThresholds: (x) => x.ReferenceID, + newSubscriptionMatrixWithDisplayName: (x) => x.ReferenceID, + newSubscriptionGroupedTieredPackage: (x) => x.ReferenceID, + newSubscriptionMaxGroupTieredPackage: (x) => x.ReferenceID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ReferenceID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ReferenceID, + newSubscriptionCumulativeGroupedBulk: (x) => x.ReferenceID, + cumulativeGroupedAllocation: (x) => x.ReferenceID, + newSubscriptionMinimumComposite: (x) => x.ReferenceID, + percent: (x) => x.ReferenceID, + eventOutput: (x) => x.ReferenceID + ); } } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func newPercentageDiscount, - System::Func newUsageDiscount, - System::Func newAmountDiscount, - System::Func newMinimum, - System::Func newMaximum - ) + public ReplacePricePrice(NewSubscriptionUnitPrice value, JsonElement? element = null) { - return this.Value switch - { - NewPercentageDiscount value => newPercentageDiscount(value), - NewUsageDiscount value => newUsageDiscount(value), - NewAmountDiscount value => newAmountDiscount(value), - NewMinimum value => newMinimum(value), - NewMaximum value => newMaximum(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplaceAdjustmentAdjustment" - ), - }; + this.Value = value; + this._element = element; } - public static implicit operator ReplaceAdjustmentAdjustment(NewPercentageDiscount value) => - new(value); - - public static implicit operator ReplaceAdjustmentAdjustment(NewUsageDiscount value) => - new(value); + public ReplacePricePrice(NewSubscriptionTieredPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - public static implicit operator ReplaceAdjustmentAdjustment(NewAmountDiscount value) => - new(value); + public ReplacePricePrice(NewSubscriptionBulkPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - public static implicit operator ReplaceAdjustmentAdjustment(NewMinimum value) => new(value); - - public static implicit operator ReplaceAdjustmentAdjustment(NewMaximum value) => new(value); - - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() + public ReplacePricePrice(ReplacePricePriceBulkWithFilters value, JsonElement? element = null) { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of ReplaceAdjustmentAdjustment" - ); - } - this.Switch( - (newPercentageDiscount) => newPercentageDiscount.Validate(), - (newUsageDiscount) => newUsageDiscount.Validate(), - (newAmountDiscount) => newAmountDiscount.Validate(), - (newMinimum) => newMinimum.Validate(), - (newMaximum) => newMaximum.Validate() - ); + this.Value = value; + this._element = element; } - public virtual bool Equals(ReplaceAdjustmentAdjustment? other) + public ReplacePricePrice(NewSubscriptionPackagePrice value, JsonElement? element = null) { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); + this.Value = value; + this._element = element; } - public override int GetHashCode() + public ReplacePricePrice(NewSubscriptionMatrixPrice value, JsonElement? element = null) { - return 0; + this.Value = value; + this._element = element; } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class ReplaceAdjustmentAdjustmentConverter : JsonConverter -{ - public override ReplaceAdjustmentAdjustment? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options + public ReplacePricePrice( + NewSubscriptionThresholdTotalAmountPrice value, + JsonElement? element = null ) { - var element = JsonSerializer.Deserialize(ref reader, options); - string? adjustmentType; - try - { - adjustmentType = element.GetProperty("adjustment_type").GetString(); - } - catch - { - adjustmentType = null; - } - - switch (adjustmentType) - { - case "percentage_discount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "usage_discount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "amount_discount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = JsonSerializer.Deserialize(element, options); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "maximum": - { - try - { - var deserialized = JsonSerializer.Deserialize(element, options); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + this.Value = value; + this._element = element; + } - return new(element); - } - default: - { - return new ReplaceAdjustmentAdjustment(element); - } - } + public ReplacePricePrice(NewSubscriptionTieredPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; } - public override void Write( - Utf8JsonWriter writer, - ReplaceAdjustmentAdjustment value, - JsonSerializerOptions options + public ReplacePricePrice( + NewSubscriptionTieredWithMinimumPrice value, + JsonElement? element = null ) { - JsonSerializer.Serialize(writer, value.Json, options); + this.Value = value; + this._element = element; } -} -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class ReplacePrice : JsonModel -{ - /// - /// The id of the price on the plan to replace in the subscription. - /// - public required string ReplacesPriceID + public ReplacePricePrice(NewSubscriptionGroupedTieredPrice value, JsonElement? element = null) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_price_id"); - } - init { this._rawData.Set("replaces_price_id", value); } + this.Value = value; + this._element = element; } - /// - /// The definition of a new allocation price to create and add to the subscription. - /// - public NewAllocationPrice? AllocationPrice + public ReplacePricePrice( + NewSubscriptionTieredPackageWithMinimumPrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("allocation_price"); - } - init { this._rawData.Set("allocation_price", value); } + this.Value = value; + this._element = element; } - /// - /// [DEPRECATED] Use add_adjustments instead. The subscription's discounts for - /// the replacement price. - /// - [System::Obsolete("deprecated")] - public IReadOnlyList? Discounts + public ReplacePricePrice( + NewSubscriptionPackageWithAllocationPrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct>("discounts"); - } - init - { - this._rawData.Set?>( - "discounts", - value == null ? null : ImmutableArray.ToImmutableArray(value) - ); - } + this.Value = value; + this._element = element; } - /// - /// The external price id of the price to add to the subscription. - /// - public string? ExternalPriceID + public ReplacePricePrice(NewSubscriptionUnitWithPercentPrice value, JsonElement? element = null) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } + this.Value = value; + this._element = element; } - /// - /// The new quantity of the price, if the price is a fixed price. - /// - public double? FixedPriceQuantity + public ReplacePricePrice( + NewSubscriptionMatrixWithAllocationPrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } + this.Value = value; + this._element = element; } - /// - /// [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount - /// for the replacement price. - /// - [System::Obsolete("deprecated")] - public string? MaximumAmount + public ReplacePricePrice( + ReplacePricePriceTieredWithProration value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("maximum_amount"); - } - init { this._rawData.Set("maximum_amount", value); } + this.Value = value; + this._element = element; } - /// - /// [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount - /// for the replacement price. - /// - [System::Obsolete("deprecated")] - public string? MinimumAmount + public ReplacePricePrice( + NewSubscriptionUnitWithProrationPrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("minimum_amount"); - } - init { this._rawData.Set("minimum_amount", value); } + this.Value = value; + this._element = element; } - /// - /// New subscription price request body params. - /// - public ReplacePricePrice? Price + public ReplacePricePrice( + NewSubscriptionGroupedAllocationPrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("price"); - } - init { this._rawData.Set("price", value); } + this.Value = value; + this._element = element; } - /// - /// The id of the price to add to the subscription. - /// - public string? PriceID + public ReplacePricePrice( + NewSubscriptionBulkWithProrationPrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("price_id"); - } - init { this._rawData.Set("price_id", value); } + this.Value = value; + this._element = element; } - /// - public override void Validate() + public ReplacePricePrice( + NewSubscriptionGroupedWithProratedMinimumPrice value, + JsonElement? element = null + ) { - _ = this.ReplacesPriceID; - this.AllocationPrice?.Validate(); - foreach (var item in this.Discounts ?? []) - { - item.Validate(); - } - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.MaximumAmount; - _ = this.MinimumAmount; - this.Price?.Validate(); - _ = this.PriceID; + this.Value = value; + this._element = element; } - public ReplacePrice() { } - - public ReplacePrice(ReplacePrice replacePrice) - : base(replacePrice) { } - - public ReplacePrice(IReadOnlyDictionary rawData) + public ReplacePricePrice( + NewSubscriptionGroupedWithMeteredMinimumPrice value, + JsonElement? element = null + ) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePrice(FrozenDictionary rawData) + public ReplacePricePrice( + ReplacePricePriceGroupedWithMinMaxThresholds value, + JsonElement? element = null + ) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning restore CS8618 - /// - public static ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) + public ReplacePricePrice( + NewSubscriptionMatrixWithDisplayNamePrice value, + JsonElement? element = null + ) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this.Value = value; + this._element = element; } - [SetsRequiredMembers] - public ReplacePrice(string replacesPriceID) - : this() + public ReplacePricePrice( + NewSubscriptionGroupedTieredPackagePrice value, + JsonElement? element = null + ) { - this.ReplacesPriceID = replacesPriceID; + this.Value = value; + this._element = element; } -} -class ReplacePriceFromRaw : IFromRawJson -{ - /// - public ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) => - ReplacePrice.FromRawUnchecked(rawData); -} + public ReplacePricePrice( + NewSubscriptionMaxGroupTieredPackagePrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } -/// -/// New subscription price request body params. -/// -[JsonConverter(typeof(ReplacePricePriceConverter))] -public record class ReplacePricePrice : ModelBase -{ - public object? Value { get; } = null; + public ReplacePricePrice( + NewSubscriptionScalableMatrixWithUnitPricingPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - JsonElement? _element = null; + public ReplacePricePrice( + NewSubscriptionScalableMatrixWithTieredPricingPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - public JsonElement Json + public ReplacePricePrice( + NewSubscriptionCumulativeGroupedBulkPrice value, + JsonElement? element = null + ) { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } + this.Value = value; + this._element = element; } - public string ItemID + public ReplacePricePrice( + ReplacePricePriceCumulativeGroupedAllocation value, + JsonElement? element = null + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.ItemID, - newSubscriptionTiered: (x) => x.ItemID, - newSubscriptionBulk: (x) => x.ItemID, - bulkWithFilters: (x) => x.ItemID, - newSubscriptionPackage: (x) => x.ItemID, - newSubscriptionMatrix: (x) => x.ItemID, - newSubscriptionThresholdTotalAmount: (x) => x.ItemID, - newSubscriptionTieredPackage: (x) => x.ItemID, - newSubscriptionTieredWithMinimum: (x) => x.ItemID, - newSubscriptionGroupedTiered: (x) => x.ItemID, - newSubscriptionTieredPackageWithMinimum: (x) => x.ItemID, - newSubscriptionPackageWithAllocation: (x) => x.ItemID, - newSubscriptionUnitWithPercent: (x) => x.ItemID, - newSubscriptionMatrixWithAllocation: (x) => x.ItemID, - tieredWithProration: (x) => x.ItemID, - newSubscriptionUnitWithProration: (x) => x.ItemID, - newSubscriptionGroupedAllocation: (x) => x.ItemID, - newSubscriptionBulkWithProration: (x) => x.ItemID, - newSubscriptionGroupedWithProratedMinimum: (x) => x.ItemID, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.ItemID, - groupedWithMinMaxThresholds: (x) => x.ItemID, - newSubscriptionMatrixWithDisplayName: (x) => x.ItemID, - newSubscriptionGroupedTieredPackage: (x) => x.ItemID, - newSubscriptionMaxGroupTieredPackage: (x) => x.ItemID, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ItemID, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ItemID, - newSubscriptionCumulativeGroupedBulk: (x) => x.ItemID, - cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, - newSubscriptionMinimumComposite: (x) => x.ItemID, - percent: (x) => x.ItemID, - eventOutput: (x) => x.ItemID - ); - } + this.Value = value; + this._element = element; } - public string Name + public ReplacePricePrice( + NewSubscriptionMinimumCompositePrice value, + JsonElement? element = null + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.Name, - newSubscriptionTiered: (x) => x.Name, - newSubscriptionBulk: (x) => x.Name, - bulkWithFilters: (x) => x.Name, - newSubscriptionPackage: (x) => x.Name, - newSubscriptionMatrix: (x) => x.Name, - newSubscriptionThresholdTotalAmount: (x) => x.Name, - newSubscriptionTieredPackage: (x) => x.Name, - newSubscriptionTieredWithMinimum: (x) => x.Name, - newSubscriptionGroupedTiered: (x) => x.Name, - newSubscriptionTieredPackageWithMinimum: (x) => x.Name, - newSubscriptionPackageWithAllocation: (x) => x.Name, - newSubscriptionUnitWithPercent: (x) => x.Name, - newSubscriptionMatrixWithAllocation: (x) => x.Name, - tieredWithProration: (x) => x.Name, - newSubscriptionUnitWithProration: (x) => x.Name, - newSubscriptionGroupedAllocation: (x) => x.Name, - newSubscriptionBulkWithProration: (x) => x.Name, - newSubscriptionGroupedWithProratedMinimum: (x) => x.Name, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.Name, - groupedWithMinMaxThresholds: (x) => x.Name, - newSubscriptionMatrixWithDisplayName: (x) => x.Name, - newSubscriptionGroupedTieredPackage: (x) => x.Name, - newSubscriptionMaxGroupTieredPackage: (x) => x.Name, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.Name, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Name, - newSubscriptionCumulativeGroupedBulk: (x) => x.Name, - cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, - newSubscriptionMinimumComposite: (x) => x.Name, - percent: (x) => x.Name, - eventOutput: (x) => x.Name - ); - } + this.Value = value; + this._element = element; } - public string? BillableMetricID + public ReplacePricePrice(ReplacePricePricePercent value, JsonElement? element = null) { - get - { - return Match( - newSubscriptionUnit: (x) => x.BillableMetricID, - newSubscriptionTiered: (x) => x.BillableMetricID, - newSubscriptionBulk: (x) => x.BillableMetricID, - bulkWithFilters: (x) => x.BillableMetricID, - newSubscriptionPackage: (x) => x.BillableMetricID, - newSubscriptionMatrix: (x) => x.BillableMetricID, - newSubscriptionThresholdTotalAmount: (x) => x.BillableMetricID, - newSubscriptionTieredPackage: (x) => x.BillableMetricID, - newSubscriptionTieredWithMinimum: (x) => x.BillableMetricID, - newSubscriptionGroupedTiered: (x) => x.BillableMetricID, - newSubscriptionTieredPackageWithMinimum: (x) => x.BillableMetricID, - newSubscriptionPackageWithAllocation: (x) => x.BillableMetricID, - newSubscriptionUnitWithPercent: (x) => x.BillableMetricID, - newSubscriptionMatrixWithAllocation: (x) => x.BillableMetricID, - tieredWithProration: (x) => x.BillableMetricID, - newSubscriptionUnitWithProration: (x) => x.BillableMetricID, - newSubscriptionGroupedAllocation: (x) => x.BillableMetricID, - newSubscriptionBulkWithProration: (x) => x.BillableMetricID, - newSubscriptionGroupedWithProratedMinimum: (x) => x.BillableMetricID, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.BillableMetricID, - groupedWithMinMaxThresholds: (x) => x.BillableMetricID, - newSubscriptionMatrixWithDisplayName: (x) => x.BillableMetricID, - newSubscriptionGroupedTieredPackage: (x) => x.BillableMetricID, - newSubscriptionMaxGroupTieredPackage: (x) => x.BillableMetricID, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BillableMetricID, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, - newSubscriptionCumulativeGroupedBulk: (x) => x.BillableMetricID, - cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, - newSubscriptionMinimumComposite: (x) => x.BillableMetricID, - percent: (x) => x.BillableMetricID, - eventOutput: (x) => x.BillableMetricID - ); - } + this.Value = value; + this._element = element; } - public bool? BilledInAdvance + public ReplacePricePrice(ReplacePricePriceEventOutput value, JsonElement? element = null) { - get - { - return Match( - newSubscriptionUnit: (x) => x.BilledInAdvance, - newSubscriptionTiered: (x) => x.BilledInAdvance, - newSubscriptionBulk: (x) => x.BilledInAdvance, - bulkWithFilters: (x) => x.BilledInAdvance, - newSubscriptionPackage: (x) => x.BilledInAdvance, - newSubscriptionMatrix: (x) => x.BilledInAdvance, - newSubscriptionThresholdTotalAmount: (x) => x.BilledInAdvance, - newSubscriptionTieredPackage: (x) => x.BilledInAdvance, - newSubscriptionTieredWithMinimum: (x) => x.BilledInAdvance, - newSubscriptionGroupedTiered: (x) => x.BilledInAdvance, - newSubscriptionTieredPackageWithMinimum: (x) => x.BilledInAdvance, - newSubscriptionPackageWithAllocation: (x) => x.BilledInAdvance, - newSubscriptionUnitWithPercent: (x) => x.BilledInAdvance, - newSubscriptionMatrixWithAllocation: (x) => x.BilledInAdvance, - tieredWithProration: (x) => x.BilledInAdvance, - newSubscriptionUnitWithProration: (x) => x.BilledInAdvance, - newSubscriptionGroupedAllocation: (x) => x.BilledInAdvance, - newSubscriptionBulkWithProration: (x) => x.BilledInAdvance, - newSubscriptionGroupedWithProratedMinimum: (x) => x.BilledInAdvance, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.BilledInAdvance, - groupedWithMinMaxThresholds: (x) => x.BilledInAdvance, - newSubscriptionMatrixWithDisplayName: (x) => x.BilledInAdvance, - newSubscriptionGroupedTieredPackage: (x) => x.BilledInAdvance, - newSubscriptionMaxGroupTieredPackage: (x) => x.BilledInAdvance, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BilledInAdvance, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, - newSubscriptionCumulativeGroupedBulk: (x) => x.BilledInAdvance, - cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, - newSubscriptionMinimumComposite: (x) => x.BilledInAdvance, - percent: (x) => x.BilledInAdvance, - eventOutput: (x) => x.BilledInAdvance - ); - } + this.Value = value; + this._element = element; } - public NewBillingCycleConfiguration? BillingCycleConfiguration + public ReplacePricePrice(JsonElement element) { - get - { - return Match( - newSubscriptionUnit: (x) => x.BillingCycleConfiguration, - newSubscriptionTiered: (x) => x.BillingCycleConfiguration, - newSubscriptionBulk: (x) => x.BillingCycleConfiguration, - bulkWithFilters: (x) => x.BillingCycleConfiguration, - newSubscriptionPackage: (x) => x.BillingCycleConfiguration, - newSubscriptionMatrix: (x) => x.BillingCycleConfiguration, - newSubscriptionThresholdTotalAmount: (x) => x.BillingCycleConfiguration, - newSubscriptionTieredPackage: (x) => x.BillingCycleConfiguration, - newSubscriptionTieredWithMinimum: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedTiered: (x) => x.BillingCycleConfiguration, - newSubscriptionTieredPackageWithMinimum: (x) => x.BillingCycleConfiguration, - newSubscriptionPackageWithAllocation: (x) => x.BillingCycleConfiguration, - newSubscriptionUnitWithPercent: (x) => x.BillingCycleConfiguration, - newSubscriptionMatrixWithAllocation: (x) => x.BillingCycleConfiguration, - tieredWithProration: (x) => x.BillingCycleConfiguration, - newSubscriptionUnitWithProration: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedAllocation: (x) => x.BillingCycleConfiguration, - newSubscriptionBulkWithProration: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedWithProratedMinimum: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.BillingCycleConfiguration, - groupedWithMinMaxThresholds: (x) => x.BillingCycleConfiguration, - newSubscriptionMatrixWithDisplayName: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedTieredPackage: (x) => x.BillingCycleConfiguration, - newSubscriptionMaxGroupTieredPackage: (x) => x.BillingCycleConfiguration, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BillingCycleConfiguration, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, - newSubscriptionCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, - cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, - newSubscriptionMinimumComposite: (x) => x.BillingCycleConfiguration, - percent: (x) => x.BillingCycleConfiguration, - eventOutput: (x) => x.BillingCycleConfiguration - ); - } + this._element = element; } - public double? ConversionRate + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionUnit(out var value)) { + /// // `value` is of type `NewSubscriptionUnitPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionUnit([NotNullWhen(true)] out NewSubscriptionUnitPrice? value) { - get - { - return Match( - newSubscriptionUnit: (x) => x.ConversionRate, - newSubscriptionTiered: (x) => x.ConversionRate, - newSubscriptionBulk: (x) => x.ConversionRate, - bulkWithFilters: (x) => x.ConversionRate, - newSubscriptionPackage: (x) => x.ConversionRate, - newSubscriptionMatrix: (x) => x.ConversionRate, - newSubscriptionThresholdTotalAmount: (x) => x.ConversionRate, - newSubscriptionTieredPackage: (x) => x.ConversionRate, - newSubscriptionTieredWithMinimum: (x) => x.ConversionRate, - newSubscriptionGroupedTiered: (x) => x.ConversionRate, - newSubscriptionTieredPackageWithMinimum: (x) => x.ConversionRate, - newSubscriptionPackageWithAllocation: (x) => x.ConversionRate, - newSubscriptionUnitWithPercent: (x) => x.ConversionRate, - newSubscriptionMatrixWithAllocation: (x) => x.ConversionRate, - tieredWithProration: (x) => x.ConversionRate, - newSubscriptionUnitWithProration: (x) => x.ConversionRate, - newSubscriptionGroupedAllocation: (x) => x.ConversionRate, - newSubscriptionBulkWithProration: (x) => x.ConversionRate, - newSubscriptionGroupedWithProratedMinimum: (x) => x.ConversionRate, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.ConversionRate, - groupedWithMinMaxThresholds: (x) => x.ConversionRate, - newSubscriptionMatrixWithDisplayName: (x) => x.ConversionRate, - newSubscriptionGroupedTieredPackage: (x) => x.ConversionRate, - newSubscriptionMaxGroupTieredPackage: (x) => x.ConversionRate, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ConversionRate, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ConversionRate, - newSubscriptionCumulativeGroupedBulk: (x) => x.ConversionRate, - cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, - newSubscriptionMinimumComposite: (x) => x.ConversionRate, - percent: (x) => x.ConversionRate, - eventOutput: (x) => x.ConversionRate - ); - } + value = this.Value as NewSubscriptionUnitPrice; + return value != null; } - public string? Currency + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionTiered(out var value)) { + /// // `value` is of type `NewSubscriptionTieredPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionTiered( + [NotNullWhen(true)] out NewSubscriptionTieredPrice? value + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.Currency, - newSubscriptionTiered: (x) => x.Currency, - newSubscriptionBulk: (x) => x.Currency, - bulkWithFilters: (x) => x.Currency, - newSubscriptionPackage: (x) => x.Currency, - newSubscriptionMatrix: (x) => x.Currency, - newSubscriptionThresholdTotalAmount: (x) => x.Currency, - newSubscriptionTieredPackage: (x) => x.Currency, - newSubscriptionTieredWithMinimum: (x) => x.Currency, - newSubscriptionGroupedTiered: (x) => x.Currency, - newSubscriptionTieredPackageWithMinimum: (x) => x.Currency, - newSubscriptionPackageWithAllocation: (x) => x.Currency, - newSubscriptionUnitWithPercent: (x) => x.Currency, - newSubscriptionMatrixWithAllocation: (x) => x.Currency, - tieredWithProration: (x) => x.Currency, - newSubscriptionUnitWithProration: (x) => x.Currency, - newSubscriptionGroupedAllocation: (x) => x.Currency, - newSubscriptionBulkWithProration: (x) => x.Currency, - newSubscriptionGroupedWithProratedMinimum: (x) => x.Currency, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.Currency, - groupedWithMinMaxThresholds: (x) => x.Currency, - newSubscriptionMatrixWithDisplayName: (x) => x.Currency, - newSubscriptionGroupedTieredPackage: (x) => x.Currency, - newSubscriptionMaxGroupTieredPackage: (x) => x.Currency, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.Currency, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Currency, - newSubscriptionCumulativeGroupedBulk: (x) => x.Currency, - cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, - newSubscriptionMinimumComposite: (x) => x.Currency, - percent: (x) => x.Currency, - eventOutput: (x) => x.Currency - ); - } + value = this.Value as NewSubscriptionTieredPrice; + return value != null; } - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionBulk(out var value)) { + /// // `value` is of type `NewSubscriptionBulkPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionBulk([NotNullWhen(true)] out NewSubscriptionBulkPrice? value) { - get - { - return Match( - newSubscriptionUnit: (x) => x.DimensionalPriceConfiguration, - newSubscriptionTiered: (x) => x.DimensionalPriceConfiguration, - newSubscriptionBulk: (x) => x.DimensionalPriceConfiguration, - bulkWithFilters: (x) => x.DimensionalPriceConfiguration, - newSubscriptionPackage: (x) => x.DimensionalPriceConfiguration, - newSubscriptionMatrix: (x) => x.DimensionalPriceConfiguration, - newSubscriptionThresholdTotalAmount: (x) => x.DimensionalPriceConfiguration, - newSubscriptionTieredPackage: (x) => x.DimensionalPriceConfiguration, - newSubscriptionTieredWithMinimum: (x) => x.DimensionalPriceConfiguration, - newSubscriptionGroupedTiered: (x) => x.DimensionalPriceConfiguration, - newSubscriptionTieredPackageWithMinimum: (x) => x.DimensionalPriceConfiguration, - newSubscriptionPackageWithAllocation: (x) => x.DimensionalPriceConfiguration, - newSubscriptionUnitWithPercent: (x) => x.DimensionalPriceConfiguration, - newSubscriptionMatrixWithAllocation: (x) => x.DimensionalPriceConfiguration, - tieredWithProration: (x) => x.DimensionalPriceConfiguration, - newSubscriptionUnitWithProration: (x) => x.DimensionalPriceConfiguration, - newSubscriptionGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - newSubscriptionBulkWithProration: (x) => x.DimensionalPriceConfiguration, - newSubscriptionGroupedWithProratedMinimum: (x) => x.DimensionalPriceConfiguration, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.DimensionalPriceConfiguration, - groupedWithMinMaxThresholds: (x) => x.DimensionalPriceConfiguration, - newSubscriptionMatrixWithDisplayName: (x) => x.DimensionalPriceConfiguration, - newSubscriptionGroupedTieredPackage: (x) => x.DimensionalPriceConfiguration, - newSubscriptionMaxGroupTieredPackage: (x) => x.DimensionalPriceConfiguration, - newSubscriptionScalableMatrixWithUnitPricing: (x) => - x.DimensionalPriceConfiguration, - newSubscriptionScalableMatrixWithTieredPricing: (x) => - x.DimensionalPriceConfiguration, - newSubscriptionCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, - cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, - newSubscriptionMinimumComposite: (x) => x.DimensionalPriceConfiguration, - percent: (x) => x.DimensionalPriceConfiguration, - eventOutput: (x) => x.DimensionalPriceConfiguration - ); - } + value = this.Value as NewSubscriptionBulkPrice; + return value != null; } - public string? ExternalPriceID + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBulkWithFilters(out var value)) { + /// // `value` is of type `ReplacePricePriceBulkWithFilters` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulkWithFilters( + [NotNullWhen(true)] out ReplacePricePriceBulkWithFilters? value + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.ExternalPriceID, - newSubscriptionTiered: (x) => x.ExternalPriceID, - newSubscriptionBulk: (x) => x.ExternalPriceID, - bulkWithFilters: (x) => x.ExternalPriceID, - newSubscriptionPackage: (x) => x.ExternalPriceID, - newSubscriptionMatrix: (x) => x.ExternalPriceID, - newSubscriptionThresholdTotalAmount: (x) => x.ExternalPriceID, - newSubscriptionTieredPackage: (x) => x.ExternalPriceID, - newSubscriptionTieredWithMinimum: (x) => x.ExternalPriceID, - newSubscriptionGroupedTiered: (x) => x.ExternalPriceID, - newSubscriptionTieredPackageWithMinimum: (x) => x.ExternalPriceID, - newSubscriptionPackageWithAllocation: (x) => x.ExternalPriceID, - newSubscriptionUnitWithPercent: (x) => x.ExternalPriceID, - newSubscriptionMatrixWithAllocation: (x) => x.ExternalPriceID, - tieredWithProration: (x) => x.ExternalPriceID, - newSubscriptionUnitWithProration: (x) => x.ExternalPriceID, - newSubscriptionGroupedAllocation: (x) => x.ExternalPriceID, - newSubscriptionBulkWithProration: (x) => x.ExternalPriceID, - newSubscriptionGroupedWithProratedMinimum: (x) => x.ExternalPriceID, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.ExternalPriceID, - groupedWithMinMaxThresholds: (x) => x.ExternalPriceID, - newSubscriptionMatrixWithDisplayName: (x) => x.ExternalPriceID, - newSubscriptionGroupedTieredPackage: (x) => x.ExternalPriceID, - newSubscriptionMaxGroupTieredPackage: (x) => x.ExternalPriceID, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ExternalPriceID, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, - newSubscriptionCumulativeGroupedBulk: (x) => x.ExternalPriceID, - cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, - newSubscriptionMinimumComposite: (x) => x.ExternalPriceID, - percent: (x) => x.ExternalPriceID, - eventOutput: (x) => x.ExternalPriceID - ); - } + value = this.Value as ReplacePricePriceBulkWithFilters; + return value != null; } - public double? FixedPriceQuantity + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionPackage(out var value)) { + /// // `value` is of type `NewSubscriptionPackagePrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionPackage( + [NotNullWhen(true)] out NewSubscriptionPackagePrice? value + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.FixedPriceQuantity, - newSubscriptionTiered: (x) => x.FixedPriceQuantity, - newSubscriptionBulk: (x) => x.FixedPriceQuantity, - bulkWithFilters: (x) => x.FixedPriceQuantity, - newSubscriptionPackage: (x) => x.FixedPriceQuantity, - newSubscriptionMatrix: (x) => x.FixedPriceQuantity, - newSubscriptionThresholdTotalAmount: (x) => x.FixedPriceQuantity, - newSubscriptionTieredPackage: (x) => x.FixedPriceQuantity, - newSubscriptionTieredWithMinimum: (x) => x.FixedPriceQuantity, - newSubscriptionGroupedTiered: (x) => x.FixedPriceQuantity, - newSubscriptionTieredPackageWithMinimum: (x) => x.FixedPriceQuantity, - newSubscriptionPackageWithAllocation: (x) => x.FixedPriceQuantity, - newSubscriptionUnitWithPercent: (x) => x.FixedPriceQuantity, - newSubscriptionMatrixWithAllocation: (x) => x.FixedPriceQuantity, - tieredWithProration: (x) => x.FixedPriceQuantity, - newSubscriptionUnitWithProration: (x) => x.FixedPriceQuantity, - newSubscriptionGroupedAllocation: (x) => x.FixedPriceQuantity, - newSubscriptionBulkWithProration: (x) => x.FixedPriceQuantity, - newSubscriptionGroupedWithProratedMinimum: (x) => x.FixedPriceQuantity, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.FixedPriceQuantity, - groupedWithMinMaxThresholds: (x) => x.FixedPriceQuantity, - newSubscriptionMatrixWithDisplayName: (x) => x.FixedPriceQuantity, - newSubscriptionGroupedTieredPackage: (x) => x.FixedPriceQuantity, - newSubscriptionMaxGroupTieredPackage: (x) => x.FixedPriceQuantity, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.FixedPriceQuantity, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, - newSubscriptionCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, - cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, - newSubscriptionMinimumComposite: (x) => x.FixedPriceQuantity, - percent: (x) => x.FixedPriceQuantity, - eventOutput: (x) => x.FixedPriceQuantity - ); - } + value = this.Value as NewSubscriptionPackagePrice; + return value != null; } - public string? InvoiceGroupingKey + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionMatrix(out var value)) { + /// // `value` is of type `NewSubscriptionMatrixPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionMatrix( + [NotNullWhen(true)] out NewSubscriptionMatrixPrice? value + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.InvoiceGroupingKey, - newSubscriptionTiered: (x) => x.InvoiceGroupingKey, - newSubscriptionBulk: (x) => x.InvoiceGroupingKey, - bulkWithFilters: (x) => x.InvoiceGroupingKey, - newSubscriptionPackage: (x) => x.InvoiceGroupingKey, - newSubscriptionMatrix: (x) => x.InvoiceGroupingKey, - newSubscriptionThresholdTotalAmount: (x) => x.InvoiceGroupingKey, - newSubscriptionTieredPackage: (x) => x.InvoiceGroupingKey, - newSubscriptionTieredWithMinimum: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedTiered: (x) => x.InvoiceGroupingKey, - newSubscriptionTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, - newSubscriptionPackageWithAllocation: (x) => x.InvoiceGroupingKey, - newSubscriptionUnitWithPercent: (x) => x.InvoiceGroupingKey, - newSubscriptionMatrixWithAllocation: (x) => x.InvoiceGroupingKey, - tieredWithProration: (x) => x.InvoiceGroupingKey, - newSubscriptionUnitWithProration: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedAllocation: (x) => x.InvoiceGroupingKey, - newSubscriptionBulkWithProration: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.InvoiceGroupingKey, - groupedWithMinMaxThresholds: (x) => x.InvoiceGroupingKey, - newSubscriptionMatrixWithDisplayName: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedTieredPackage: (x) => x.InvoiceGroupingKey, - newSubscriptionMaxGroupTieredPackage: (x) => x.InvoiceGroupingKey, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, - newSubscriptionCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, - cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, - newSubscriptionMinimumComposite: (x) => x.InvoiceGroupingKey, - percent: (x) => x.InvoiceGroupingKey, - eventOutput: (x) => x.InvoiceGroupingKey - ); - } + value = this.Value as NewSubscriptionMatrixPrice; + return value != null; } - public NewBillingCycleConfiguration? InvoicingCycleConfiguration - { - get - { - return Match( - newSubscriptionUnit: (x) => x.InvoicingCycleConfiguration, - newSubscriptionTiered: (x) => x.InvoicingCycleConfiguration, - newSubscriptionBulk: (x) => x.InvoicingCycleConfiguration, - bulkWithFilters: (x) => x.InvoicingCycleConfiguration, - newSubscriptionPackage: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMatrix: (x) => x.InvoicingCycleConfiguration, - newSubscriptionThresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, - newSubscriptionTieredPackage: (x) => x.InvoicingCycleConfiguration, - newSubscriptionTieredWithMinimum: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedTiered: (x) => x.InvoicingCycleConfiguration, - newSubscriptionTieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, - newSubscriptionPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, - newSubscriptionUnitWithPercent: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, - tieredWithProration: (x) => x.InvoicingCycleConfiguration, - newSubscriptionUnitWithProration: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - newSubscriptionBulkWithProration: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedWithProratedMinimum: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.InvoicingCycleConfiguration, - groupedWithMinMaxThresholds: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMatrixWithDisplayName: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedTieredPackage: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMaxGroupTieredPackage: (x) => x.InvoicingCycleConfiguration, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.InvoicingCycleConfiguration, - newSubscriptionScalableMatrixWithTieredPricing: (x) => - x.InvoicingCycleConfiguration, - newSubscriptionCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, - cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMinimumComposite: (x) => x.InvoicingCycleConfiguration, - percent: (x) => x.InvoicingCycleConfiguration, - eventOutput: (x) => x.InvoicingCycleConfiguration - ); - } - } - - public string? ReferenceID - { - get - { - return Match( - newSubscriptionUnit: (x) => x.ReferenceID, - newSubscriptionTiered: (x) => x.ReferenceID, - newSubscriptionBulk: (x) => x.ReferenceID, - bulkWithFilters: (x) => x.ReferenceID, - newSubscriptionPackage: (x) => x.ReferenceID, - newSubscriptionMatrix: (x) => x.ReferenceID, - newSubscriptionThresholdTotalAmount: (x) => x.ReferenceID, - newSubscriptionTieredPackage: (x) => x.ReferenceID, - newSubscriptionTieredWithMinimum: (x) => x.ReferenceID, - newSubscriptionGroupedTiered: (x) => x.ReferenceID, - newSubscriptionTieredPackageWithMinimum: (x) => x.ReferenceID, - newSubscriptionPackageWithAllocation: (x) => x.ReferenceID, - newSubscriptionUnitWithPercent: (x) => x.ReferenceID, - newSubscriptionMatrixWithAllocation: (x) => x.ReferenceID, - tieredWithProration: (x) => x.ReferenceID, - newSubscriptionUnitWithProration: (x) => x.ReferenceID, - newSubscriptionGroupedAllocation: (x) => x.ReferenceID, - newSubscriptionBulkWithProration: (x) => x.ReferenceID, - newSubscriptionGroupedWithProratedMinimum: (x) => x.ReferenceID, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.ReferenceID, - groupedWithMinMaxThresholds: (x) => x.ReferenceID, - newSubscriptionMatrixWithDisplayName: (x) => x.ReferenceID, - newSubscriptionGroupedTieredPackage: (x) => x.ReferenceID, - newSubscriptionMaxGroupTieredPackage: (x) => x.ReferenceID, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ReferenceID, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ReferenceID, - newSubscriptionCumulativeGroupedBulk: (x) => x.ReferenceID, - cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, - newSubscriptionMinimumComposite: (x) => x.ReferenceID, - percent: (x) => x.ReferenceID, - eventOutput: (x) => x.ReferenceID - ); - } - } - - public ReplacePricePrice(NewSubscriptionUnitPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewSubscriptionTieredPrice value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionThresholdTotalAmount(out var value)) { + /// // `value` is of type `NewSubscriptionThresholdTotalAmountPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionThresholdTotalAmount( + [NotNullWhen(true)] out NewSubscriptionThresholdTotalAmountPrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionThresholdTotalAmountPrice; + return value != null; } - public ReplacePricePrice(NewSubscriptionBulkPrice value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionTieredPackage(out var value)) { + /// // `value` is of type `NewSubscriptionTieredPackagePrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionTieredPackage( + [NotNullWhen(true)] out NewSubscriptionTieredPackagePrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionTieredPackagePrice; + return value != null; } - public ReplacePricePrice(ReplacePricePriceBulkWithFilters value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionTieredWithMinimum(out var value)) { + /// // `value` is of type `NewSubscriptionTieredWithMinimumPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionTieredWithMinimum( + [NotNullWhen(true)] out NewSubscriptionTieredWithMinimumPrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionTieredWithMinimumPrice; + return value != null; } - public ReplacePricePrice(NewSubscriptionPackagePrice value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionGroupedTiered(out var value)) { + /// // `value` is of type `NewSubscriptionGroupedTieredPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionGroupedTiered( + [NotNullWhen(true)] out NewSubscriptionGroupedTieredPrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionGroupedTieredPrice; + return value != null; } - public ReplacePricePrice(NewSubscriptionMatrixPrice value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionTieredPackageWithMinimum(out var value)) { + /// // `value` is of type `NewSubscriptionTieredPackageWithMinimumPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionTieredPackageWithMinimum( + [NotNullWhen(true)] out NewSubscriptionTieredPackageWithMinimumPrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionTieredPackageWithMinimumPrice; + return value != null; } - public ReplacePricePrice( - NewSubscriptionThresholdTotalAmountPrice value, - JsonElement? element = null + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionPackageWithAllocation(out var value)) { + /// // `value` is of type `NewSubscriptionPackageWithAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionPackageWithAllocation( + [NotNullWhen(true)] out NewSubscriptionPackageWithAllocationPrice? value ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionPackageWithAllocationPrice; + return value != null; } - public ReplacePricePrice(NewSubscriptionTieredPackagePrice value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionUnitWithPercent(out var value)) { + /// // `value` is of type `NewSubscriptionUnitWithPercentPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionUnitWithPercent( + [NotNullWhen(true)] out NewSubscriptionUnitWithPercentPrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionUnitWithPercentPrice; + return value != null; } - public ReplacePricePrice( - NewSubscriptionTieredWithMinimumPrice value, - JsonElement? element = null + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionMatrixWithAllocation(out var value)) { + /// // `value` is of type `NewSubscriptionMatrixWithAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionMatrixWithAllocation( + [NotNullWhen(true)] out NewSubscriptionMatrixWithAllocationPrice? value ) { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewSubscriptionGroupedTieredPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionTieredPackageWithMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionPackageWithAllocationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewSubscriptionUnitWithPercentPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionMatrixWithAllocationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - ReplacePricePriceTieredWithProration value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionUnitWithProrationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionGroupedAllocationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionBulkWithProrationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionGroupedWithProratedMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionGroupedWithMeteredMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - ReplacePricePriceGroupedWithMinMaxThresholds value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionMatrixWithDisplayNamePrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionGroupedTieredPackagePrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionMaxGroupTieredPackagePrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionScalableMatrixWithUnitPricingPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionScalableMatrixWithTieredPricingPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionCumulativeGroupedBulkPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - ReplacePricePriceCumulativeGroupedAllocation value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(ReplacePricePriceMinimum value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionMinimumCompositePrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(ReplacePricePricePercent value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(ReplacePricePriceEventOutput value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(JsonElement element) - { - this._element = element; + value = this.Value as NewSubscriptionMatrixWithAllocationPrice; + return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionUnit(out var value)) { - /// // `value` is of type `NewSubscriptionUnitPrice` + /// if (instance.TryPickTieredWithProration(out var value)) { + /// // `value` is of type `ReplacePricePriceTieredWithProration` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionUnit([NotNullWhen(true)] out NewSubscriptionUnitPrice? value) + public bool TryPickTieredWithProration( + [NotNullWhen(true)] out ReplacePricePriceTieredWithProration? value + ) { - value = this.Value as NewSubscriptionUnitPrice; + value = this.Value as ReplacePricePriceTieredWithProration; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionTiered(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPrice` + /// if (instance.TryPickNewSubscriptionUnitWithProration(out var value)) { + /// // `value` is of type `NewSubscriptionUnitWithProrationPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionTiered( - [NotNullWhen(true)] out NewSubscriptionTieredPrice? value + public bool TryPickNewSubscriptionUnitWithProration( + [NotNullWhen(true)] out NewSubscriptionUnitWithProrationPrice? value ) { - value = this.Value as NewSubscriptionTieredPrice; + value = this.Value as NewSubscriptionUnitWithProrationPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionBulk(out var value)) { - /// // `value` is of type `NewSubscriptionBulkPrice` + /// if (instance.TryPickNewSubscriptionGroupedAllocation(out var value)) { + /// // `value` is of type `NewSubscriptionGroupedAllocationPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionBulk([NotNullWhen(true)] out NewSubscriptionBulkPrice? value) + public bool TryPickNewSubscriptionGroupedAllocation( + [NotNullWhen(true)] out NewSubscriptionGroupedAllocationPrice? value + ) { - value = this.Value as NewSubscriptionBulkPrice; + value = this.Value as NewSubscriptionGroupedAllocationPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickBulkWithFilters(out var value)) { - /// // `value` is of type `ReplacePricePriceBulkWithFilters` + /// if (instance.TryPickNewSubscriptionBulkWithProration(out var value)) { + /// // `value` is of type `NewSubscriptionBulkWithProrationPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickBulkWithFilters( - [NotNullWhen(true)] out ReplacePricePriceBulkWithFilters? value + public bool TryPickNewSubscriptionBulkWithProration( + [NotNullWhen(true)] out NewSubscriptionBulkWithProrationPrice? value ) { - value = this.Value as ReplacePricePriceBulkWithFilters; + value = this.Value as NewSubscriptionBulkWithProrationPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionPackage(out var value)) { - /// // `value` is of type `NewSubscriptionPackagePrice` + /// if (instance.TryPickNewSubscriptionGroupedWithProratedMinimum(out var value)) { + /// // `value` is of type `NewSubscriptionGroupedWithProratedMinimumPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionPackage( - [NotNullWhen(true)] out NewSubscriptionPackagePrice? value + public bool TryPickNewSubscriptionGroupedWithProratedMinimum( + [NotNullWhen(true)] out NewSubscriptionGroupedWithProratedMinimumPrice? value ) { - value = this.Value as NewSubscriptionPackagePrice; + value = this.Value as NewSubscriptionGroupedWithProratedMinimumPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionMatrix(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixPrice` + /// if (instance.TryPickNewSubscriptionGroupedWithMeteredMinimum(out var value)) { + /// // `value` is of type `NewSubscriptionGroupedWithMeteredMinimumPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionMatrix( - [NotNullWhen(true)] out NewSubscriptionMatrixPrice? value + public bool TryPickNewSubscriptionGroupedWithMeteredMinimum( + [NotNullWhen(true)] out NewSubscriptionGroupedWithMeteredMinimumPrice? value ) { - value = this.Value as NewSubscriptionMatrixPrice; + value = this.Value as NewSubscriptionGroupedWithMeteredMinimumPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionThresholdTotalAmount(out var value)) { - /// // `value` is of type `NewSubscriptionThresholdTotalAmountPrice` + /// if (instance.TryPickGroupedWithMinMaxThresholds(out var value)) { + /// // `value` is of type `ReplacePricePriceGroupedWithMinMaxThresholds` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionThresholdTotalAmount( - [NotNullWhen(true)] out NewSubscriptionThresholdTotalAmountPrice? value + public bool TryPickGroupedWithMinMaxThresholds( + [NotNullWhen(true)] out ReplacePricePriceGroupedWithMinMaxThresholds? value ) { - value = this.Value as NewSubscriptionThresholdTotalAmountPrice; + value = this.Value as ReplacePricePriceGroupedWithMinMaxThresholds; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionTieredPackage(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPackagePrice` + /// if (instance.TryPickNewSubscriptionMatrixWithDisplayName(out var value)) { + /// // `value` is of type `NewSubscriptionMatrixWithDisplayNamePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionTieredPackage( - [NotNullWhen(true)] out NewSubscriptionTieredPackagePrice? value + public bool TryPickNewSubscriptionMatrixWithDisplayName( + [NotNullWhen(true)] out NewSubscriptionMatrixWithDisplayNamePrice? value ) { - value = this.Value as NewSubscriptionTieredPackagePrice; + value = this.Value as NewSubscriptionMatrixWithDisplayNamePrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionTieredWithMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionTieredWithMinimumPrice` + /// if (instance.TryPickNewSubscriptionGroupedTieredPackage(out var value)) { + /// // `value` is of type `NewSubscriptionGroupedTieredPackagePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionTieredWithMinimum( - [NotNullWhen(true)] out NewSubscriptionTieredWithMinimumPrice? value + public bool TryPickNewSubscriptionGroupedTieredPackage( + [NotNullWhen(true)] out NewSubscriptionGroupedTieredPackagePrice? value ) { - value = this.Value as NewSubscriptionTieredWithMinimumPrice; + value = this.Value as NewSubscriptionGroupedTieredPackagePrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionGroupedTiered(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedTieredPrice` + /// if (instance.TryPickNewSubscriptionMaxGroupTieredPackage(out var value)) { + /// // `value` is of type `NewSubscriptionMaxGroupTieredPackagePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionGroupedTiered( - [NotNullWhen(true)] out NewSubscriptionGroupedTieredPrice? value + public bool TryPickNewSubscriptionMaxGroupTieredPackage( + [NotNullWhen(true)] out NewSubscriptionMaxGroupTieredPackagePrice? value ) { - value = this.Value as NewSubscriptionGroupedTieredPrice; + value = this.Value as NewSubscriptionMaxGroupTieredPackagePrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionTieredPackageWithMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPackageWithMinimumPrice` + /// if (instance.TryPickNewSubscriptionScalableMatrixWithUnitPricing(out var value)) { + /// // `value` is of type `NewSubscriptionScalableMatrixWithUnitPricingPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionTieredPackageWithMinimum( - [NotNullWhen(true)] out NewSubscriptionTieredPackageWithMinimumPrice? value + public bool TryPickNewSubscriptionScalableMatrixWithUnitPricing( + [NotNullWhen(true)] out NewSubscriptionScalableMatrixWithUnitPricingPrice? value ) { - value = this.Value as NewSubscriptionTieredPackageWithMinimumPrice; + value = this.Value as NewSubscriptionScalableMatrixWithUnitPricingPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionPackageWithAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionPackageWithAllocationPrice` + /// if (instance.TryPickNewSubscriptionScalableMatrixWithTieredPricing(out var value)) { + /// // `value` is of type `NewSubscriptionScalableMatrixWithTieredPricingPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionPackageWithAllocation( - [NotNullWhen(true)] out NewSubscriptionPackageWithAllocationPrice? value + public bool TryPickNewSubscriptionScalableMatrixWithTieredPricing( + [NotNullWhen(true)] out NewSubscriptionScalableMatrixWithTieredPricingPrice? value ) { - value = this.Value as NewSubscriptionPackageWithAllocationPrice; + value = this.Value as NewSubscriptionScalableMatrixWithTieredPricingPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionUnitWithPercent(out var value)) { - /// // `value` is of type `NewSubscriptionUnitWithPercentPrice` + /// if (instance.TryPickNewSubscriptionCumulativeGroupedBulk(out var value)) { + /// // `value` is of type `NewSubscriptionCumulativeGroupedBulkPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionUnitWithPercent( - [NotNullWhen(true)] out NewSubscriptionUnitWithPercentPrice? value + public bool TryPickNewSubscriptionCumulativeGroupedBulk( + [NotNullWhen(true)] out NewSubscriptionCumulativeGroupedBulkPrice? value ) { - value = this.Value as NewSubscriptionUnitWithPercentPrice; + value = this.Value as NewSubscriptionCumulativeGroupedBulkPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionMatrixWithAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixWithAllocationPrice` + /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { + /// // `value` is of type `ReplacePricePriceCumulativeGroupedAllocation` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionMatrixWithAllocation( - [NotNullWhen(true)] out NewSubscriptionMatrixWithAllocationPrice? value + public bool TryPickCumulativeGroupedAllocation( + [NotNullWhen(true)] out ReplacePricePriceCumulativeGroupedAllocation? value ) { - value = this.Value as NewSubscriptionMatrixWithAllocationPrice; + value = this.Value as ReplacePricePriceCumulativeGroupedAllocation; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickTieredWithProration(out var value)) { - /// // `value` is of type `ReplacePricePriceTieredWithProration` + /// if (instance.TryPickNewSubscriptionMinimumComposite(out var value)) { + /// // `value` is of type `NewSubscriptionMinimumCompositePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTieredWithProration( - [NotNullWhen(true)] out ReplacePricePriceTieredWithProration? value + public bool TryPickNewSubscriptionMinimumComposite( + [NotNullWhen(true)] out NewSubscriptionMinimumCompositePrice? value ) { - value = this.Value as ReplacePricePriceTieredWithProration; + value = this.Value as NewSubscriptionMinimumCompositePrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionUnitWithProration(out var value)) { - /// // `value` is of type `NewSubscriptionUnitWithProrationPrice` + /// if (instance.TryPickPercent(out var value)) { + /// // `value` is of type `ReplacePricePricePercent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionUnitWithProration( - [NotNullWhen(true)] out NewSubscriptionUnitWithProrationPrice? value - ) + public bool TryPickPercent([NotNullWhen(true)] out ReplacePricePricePercent? value) { - value = this.Value as NewSubscriptionUnitWithProrationPrice; + value = this.Value as ReplacePricePricePercent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionGroupedAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedAllocationPrice` + /// if (instance.TryPickEventOutput(out var value)) { + /// // `value` is of type `ReplacePricePriceEventOutput` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionGroupedAllocation( - [NotNullWhen(true)] out NewSubscriptionGroupedAllocationPrice? value - ) + public bool TryPickEventOutput([NotNullWhen(true)] out ReplacePricePriceEventOutput? value) { - value = this.Value as NewSubscriptionGroupedAllocationPrice; + value = this.Value as ReplacePricePriceEventOutput; return value != null; } /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. + /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// - /// - /// if (instance.TryPickNewSubscriptionBulkWithProration(out var value)) { - /// // `value` is of type `NewSubscriptionBulkWithProrationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionBulkWithProration( - [NotNullWhen(true)] out NewSubscriptionBulkWithProrationPrice? value - ) - { - value = this.Value as NewSubscriptionBulkWithProrationPrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. /// - /// Consider using or if you need to handle every variant. + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// /// /// /// - /// if (instance.TryPickNewSubscriptionGroupedWithProratedMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedWithProratedMinimumPrice` - /// Console.WriteLine(value); - /// } + /// instance.Switch( + /// (NewSubscriptionUnitPrice value) => {...}, + /// (NewSubscriptionTieredPrice value) => {...}, + /// (NewSubscriptionBulkPrice value) => {...}, + /// (ReplacePricePriceBulkWithFilters value) => {...}, + /// (NewSubscriptionPackagePrice value) => {...}, + /// (NewSubscriptionMatrixPrice value) => {...}, + /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, + /// (NewSubscriptionTieredPackagePrice value) => {...}, + /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedTieredPrice value) => {...}, + /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, + /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, + /// (NewSubscriptionUnitWithPercentPrice value) => {...}, + /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, + /// (ReplacePricePriceTieredWithProration value) => {...}, + /// (NewSubscriptionUnitWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedAllocationPrice value) => {...}, + /// (NewSubscriptionBulkWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, + /// (ReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, + /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, + /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, + /// (ReplacePricePriceCumulativeGroupedAllocation value) => {...}, + /// (NewSubscriptionMinimumCompositePrice value) => {...}, + /// (ReplacePricePricePercent value) => {...}, + /// (ReplacePricePriceEventOutput value) => {...} + /// ); /// /// /// - public bool TryPickNewSubscriptionGroupedWithProratedMinimum( - [NotNullWhen(true)] out NewSubscriptionGroupedWithProratedMinimumPrice? value + public void Switch( + System::Action newSubscriptionUnit, + System::Action newSubscriptionTiered, + System::Action newSubscriptionBulk, + System::Action bulkWithFilters, + System::Action newSubscriptionPackage, + System::Action newSubscriptionMatrix, + System::Action newSubscriptionThresholdTotalAmount, + System::Action newSubscriptionTieredPackage, + System::Action newSubscriptionTieredWithMinimum, + System::Action newSubscriptionGroupedTiered, + System::Action newSubscriptionTieredPackageWithMinimum, + System::Action newSubscriptionPackageWithAllocation, + System::Action newSubscriptionUnitWithPercent, + System::Action newSubscriptionMatrixWithAllocation, + System::Action tieredWithProration, + System::Action newSubscriptionUnitWithProration, + System::Action newSubscriptionGroupedAllocation, + System::Action newSubscriptionBulkWithProration, + System::Action newSubscriptionGroupedWithProratedMinimum, + System::Action newSubscriptionGroupedWithMeteredMinimum, + System::Action groupedWithMinMaxThresholds, + System::Action newSubscriptionMatrixWithDisplayName, + System::Action newSubscriptionGroupedTieredPackage, + System::Action newSubscriptionMaxGroupTieredPackage, + System::Action newSubscriptionScalableMatrixWithUnitPricing, + System::Action newSubscriptionScalableMatrixWithTieredPricing, + System::Action newSubscriptionCumulativeGroupedBulk, + System::Action cumulativeGroupedAllocation, + System::Action newSubscriptionMinimumComposite, + System::Action percent, + System::Action eventOutput ) { - value = this.Value as NewSubscriptionGroupedWithProratedMinimumPrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionGroupedWithMeteredMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedWithMeteredMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionGroupedWithMeteredMinimum( - [NotNullWhen(true)] out NewSubscriptionGroupedWithMeteredMinimumPrice? value - ) - { - value = this.Value as NewSubscriptionGroupedWithMeteredMinimumPrice; - return value != null; + switch (this.Value) + { + case NewSubscriptionUnitPrice value: + newSubscriptionUnit(value); + break; + case NewSubscriptionTieredPrice value: + newSubscriptionTiered(value); + break; + case NewSubscriptionBulkPrice value: + newSubscriptionBulk(value); + break; + case ReplacePricePriceBulkWithFilters value: + bulkWithFilters(value); + break; + case NewSubscriptionPackagePrice value: + newSubscriptionPackage(value); + break; + case NewSubscriptionMatrixPrice value: + newSubscriptionMatrix(value); + break; + case NewSubscriptionThresholdTotalAmountPrice value: + newSubscriptionThresholdTotalAmount(value); + break; + case NewSubscriptionTieredPackagePrice value: + newSubscriptionTieredPackage(value); + break; + case NewSubscriptionTieredWithMinimumPrice value: + newSubscriptionTieredWithMinimum(value); + break; + case NewSubscriptionGroupedTieredPrice value: + newSubscriptionGroupedTiered(value); + break; + case NewSubscriptionTieredPackageWithMinimumPrice value: + newSubscriptionTieredPackageWithMinimum(value); + break; + case NewSubscriptionPackageWithAllocationPrice value: + newSubscriptionPackageWithAllocation(value); + break; + case NewSubscriptionUnitWithPercentPrice value: + newSubscriptionUnitWithPercent(value); + break; + case NewSubscriptionMatrixWithAllocationPrice value: + newSubscriptionMatrixWithAllocation(value); + break; + case ReplacePricePriceTieredWithProration value: + tieredWithProration(value); + break; + case NewSubscriptionUnitWithProrationPrice value: + newSubscriptionUnitWithProration(value); + break; + case NewSubscriptionGroupedAllocationPrice value: + newSubscriptionGroupedAllocation(value); + break; + case NewSubscriptionBulkWithProrationPrice value: + newSubscriptionBulkWithProration(value); + break; + case NewSubscriptionGroupedWithProratedMinimumPrice value: + newSubscriptionGroupedWithProratedMinimum(value); + break; + case NewSubscriptionGroupedWithMeteredMinimumPrice value: + newSubscriptionGroupedWithMeteredMinimum(value); + break; + case ReplacePricePriceGroupedWithMinMaxThresholds value: + groupedWithMinMaxThresholds(value); + break; + case NewSubscriptionMatrixWithDisplayNamePrice value: + newSubscriptionMatrixWithDisplayName(value); + break; + case NewSubscriptionGroupedTieredPackagePrice value: + newSubscriptionGroupedTieredPackage(value); + break; + case NewSubscriptionMaxGroupTieredPackagePrice value: + newSubscriptionMaxGroupTieredPackage(value); + break; + case NewSubscriptionScalableMatrixWithUnitPricingPrice value: + newSubscriptionScalableMatrixWithUnitPricing(value); + break; + case NewSubscriptionScalableMatrixWithTieredPricingPrice value: + newSubscriptionScalableMatrixWithTieredPricing(value); + break; + case NewSubscriptionCumulativeGroupedBulkPrice value: + newSubscriptionCumulativeGroupedBulk(value); + break; + case ReplacePricePriceCumulativeGroupedAllocation value: + cumulativeGroupedAllocation(value); + break; + case NewSubscriptionMinimumCompositePrice value: + newSubscriptionMinimumComposite(value); + break; + case ReplacePricePricePercent value: + percent(value); + break; + case ReplacePricePriceEventOutput value: + eventOutput(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePrice" + ); + } } /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. /// - /// - /// - /// if (instance.TryPickGroupedWithMinMaxThresholds(out var value)) { - /// // `value` is of type `ReplacePricePriceGroupedWithMinMaxThresholds` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] out ReplacePricePriceGroupedWithMinMaxThresholds? value - ) - { - value = this.Value as ReplacePricePriceGroupedWithMinMaxThresholds; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. /// - /// Consider using or if you need to handle every variant. + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// /// /// /// - /// if (instance.TryPickNewSubscriptionMatrixWithDisplayName(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixWithDisplayNamePrice` - /// Console.WriteLine(value); - /// } + /// var result = instance.Match( + /// (NewSubscriptionUnitPrice value) => {...}, + /// (NewSubscriptionTieredPrice value) => {...}, + /// (NewSubscriptionBulkPrice value) => {...}, + /// (ReplacePricePriceBulkWithFilters value) => {...}, + /// (NewSubscriptionPackagePrice value) => {...}, + /// (NewSubscriptionMatrixPrice value) => {...}, + /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, + /// (NewSubscriptionTieredPackagePrice value) => {...}, + /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedTieredPrice value) => {...}, + /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, + /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, + /// (NewSubscriptionUnitWithPercentPrice value) => {...}, + /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, + /// (ReplacePricePriceTieredWithProration value) => {...}, + /// (NewSubscriptionUnitWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedAllocationPrice value) => {...}, + /// (NewSubscriptionBulkWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, + /// (ReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, + /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, + /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, + /// (ReplacePricePriceCumulativeGroupedAllocation value) => {...}, + /// (NewSubscriptionMinimumCompositePrice value) => {...}, + /// (ReplacePricePricePercent value) => {...}, + /// (ReplacePricePriceEventOutput value) => {...} + /// ); /// /// /// - public bool TryPickNewSubscriptionMatrixWithDisplayName( - [NotNullWhen(true)] out NewSubscriptionMatrixWithDisplayNamePrice? value + public T Match( + System::Func newSubscriptionUnit, + System::Func newSubscriptionTiered, + System::Func newSubscriptionBulk, + System::Func bulkWithFilters, + System::Func newSubscriptionPackage, + System::Func newSubscriptionMatrix, + System::Func< + NewSubscriptionThresholdTotalAmountPrice, + T + > newSubscriptionThresholdTotalAmount, + System::Func newSubscriptionTieredPackage, + System::Func newSubscriptionTieredWithMinimum, + System::Func newSubscriptionGroupedTiered, + System::Func< + NewSubscriptionTieredPackageWithMinimumPrice, + T + > newSubscriptionTieredPackageWithMinimum, + System::Func< + NewSubscriptionPackageWithAllocationPrice, + T + > newSubscriptionPackageWithAllocation, + System::Func newSubscriptionUnitWithPercent, + System::Func< + NewSubscriptionMatrixWithAllocationPrice, + T + > newSubscriptionMatrixWithAllocation, + System::Func tieredWithProration, + System::Func newSubscriptionUnitWithProration, + System::Func newSubscriptionGroupedAllocation, + System::Func newSubscriptionBulkWithProration, + System::Func< + NewSubscriptionGroupedWithProratedMinimumPrice, + T + > newSubscriptionGroupedWithProratedMinimum, + System::Func< + NewSubscriptionGroupedWithMeteredMinimumPrice, + T + > newSubscriptionGroupedWithMeteredMinimum, + System::Func groupedWithMinMaxThresholds, + System::Func< + NewSubscriptionMatrixWithDisplayNamePrice, + T + > newSubscriptionMatrixWithDisplayName, + System::Func< + NewSubscriptionGroupedTieredPackagePrice, + T + > newSubscriptionGroupedTieredPackage, + System::Func< + NewSubscriptionMaxGroupTieredPackagePrice, + T + > newSubscriptionMaxGroupTieredPackage, + System::Func< + NewSubscriptionScalableMatrixWithUnitPricingPrice, + T + > newSubscriptionScalableMatrixWithUnitPricing, + System::Func< + NewSubscriptionScalableMatrixWithTieredPricingPrice, + T + > newSubscriptionScalableMatrixWithTieredPricing, + System::Func< + NewSubscriptionCumulativeGroupedBulkPrice, + T + > newSubscriptionCumulativeGroupedBulk, + System::Func cumulativeGroupedAllocation, + System::Func newSubscriptionMinimumComposite, + System::Func percent, + System::Func eventOutput ) { - value = this.Value as NewSubscriptionMatrixWithDisplayNamePrice; - return value != null; + return this.Value switch + { + NewSubscriptionUnitPrice value => newSubscriptionUnit(value), + NewSubscriptionTieredPrice value => newSubscriptionTiered(value), + NewSubscriptionBulkPrice value => newSubscriptionBulk(value), + ReplacePricePriceBulkWithFilters value => bulkWithFilters(value), + NewSubscriptionPackagePrice value => newSubscriptionPackage(value), + NewSubscriptionMatrixPrice value => newSubscriptionMatrix(value), + NewSubscriptionThresholdTotalAmountPrice value => newSubscriptionThresholdTotalAmount( + value + ), + NewSubscriptionTieredPackagePrice value => newSubscriptionTieredPackage(value), + NewSubscriptionTieredWithMinimumPrice value => newSubscriptionTieredWithMinimum(value), + NewSubscriptionGroupedTieredPrice value => newSubscriptionGroupedTiered(value), + NewSubscriptionTieredPackageWithMinimumPrice value => + newSubscriptionTieredPackageWithMinimum(value), + NewSubscriptionPackageWithAllocationPrice value => newSubscriptionPackageWithAllocation( + value + ), + NewSubscriptionUnitWithPercentPrice value => newSubscriptionUnitWithPercent(value), + NewSubscriptionMatrixWithAllocationPrice value => newSubscriptionMatrixWithAllocation( + value + ), + ReplacePricePriceTieredWithProration value => tieredWithProration(value), + NewSubscriptionUnitWithProrationPrice value => newSubscriptionUnitWithProration(value), + NewSubscriptionGroupedAllocationPrice value => newSubscriptionGroupedAllocation(value), + NewSubscriptionBulkWithProrationPrice value => newSubscriptionBulkWithProration(value), + NewSubscriptionGroupedWithProratedMinimumPrice value => + newSubscriptionGroupedWithProratedMinimum(value), + NewSubscriptionGroupedWithMeteredMinimumPrice value => + newSubscriptionGroupedWithMeteredMinimum(value), + ReplacePricePriceGroupedWithMinMaxThresholds value => groupedWithMinMaxThresholds( + value + ), + NewSubscriptionMatrixWithDisplayNamePrice value => newSubscriptionMatrixWithDisplayName( + value + ), + NewSubscriptionGroupedTieredPackagePrice value => newSubscriptionGroupedTieredPackage( + value + ), + NewSubscriptionMaxGroupTieredPackagePrice value => newSubscriptionMaxGroupTieredPackage( + value + ), + NewSubscriptionScalableMatrixWithUnitPricingPrice value => + newSubscriptionScalableMatrixWithUnitPricing(value), + NewSubscriptionScalableMatrixWithTieredPricingPrice value => + newSubscriptionScalableMatrixWithTieredPricing(value), + NewSubscriptionCumulativeGroupedBulkPrice value => newSubscriptionCumulativeGroupedBulk( + value + ), + ReplacePricePriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation( + value + ), + NewSubscriptionMinimumCompositePrice value => newSubscriptionMinimumComposite(value), + ReplacePricePricePercent value => percent(value), + ReplacePricePriceEventOutput value => eventOutput(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePrice" + ), + }; } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionGroupedTieredPackage(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionGroupedTieredPackage( - [NotNullWhen(true)] out NewSubscriptionGroupedTieredPackagePrice? value - ) - { - value = this.Value as NewSubscriptionGroupedTieredPackagePrice; - return value != null; - } + public static implicit operator ReplacePricePrice(NewSubscriptionUnitPrice value) => new(value); - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionMaxGroupTieredPackage(out var value)) { - /// // `value` is of type `NewSubscriptionMaxGroupTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMaxGroupTieredPackage( - [NotNullWhen(true)] out NewSubscriptionMaxGroupTieredPackagePrice? value - ) - { - value = this.Value as NewSubscriptionMaxGroupTieredPackagePrice; - return value != null; - } + public static implicit operator ReplacePricePrice(NewSubscriptionTieredPrice value) => + new(value); - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionScalableMatrixWithUnitPricing(out var value)) { - /// // `value` is of type `NewSubscriptionScalableMatrixWithUnitPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionScalableMatrixWithUnitPricing( - [NotNullWhen(true)] out NewSubscriptionScalableMatrixWithUnitPricingPrice? value - ) - { - value = this.Value as NewSubscriptionScalableMatrixWithUnitPricingPrice; - return value != null; - } + public static implicit operator ReplacePricePrice(NewSubscriptionBulkPrice value) => new(value); - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionScalableMatrixWithTieredPricing(out var value)) { - /// // `value` is of type `NewSubscriptionScalableMatrixWithTieredPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionScalableMatrixWithTieredPricing( - [NotNullWhen(true)] out NewSubscriptionScalableMatrixWithTieredPricingPrice? value - ) - { - value = this.Value as NewSubscriptionScalableMatrixWithTieredPricingPrice; - return value != null; - } + public static implicit operator ReplacePricePrice(ReplacePricePriceBulkWithFilters value) => + new(value); - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionCumulativeGroupedBulk(out var value)) { - /// // `value` is of type `NewSubscriptionCumulativeGroupedBulkPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionCumulativeGroupedBulk( - [NotNullWhen(true)] out NewSubscriptionCumulativeGroupedBulkPrice? value - ) - { - value = this.Value as NewSubscriptionCumulativeGroupedBulkPrice; - return value != null; - } + public static implicit operator ReplacePricePrice(NewSubscriptionPackagePrice value) => + new(value); - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `ReplacePricePriceCumulativeGroupedAllocation` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] out ReplacePricePriceCumulativeGroupedAllocation? value - ) - { - value = this.Value as ReplacePricePriceCumulativeGroupedAllocation; - return value != null; - } + public static implicit operator ReplacePricePrice(NewSubscriptionMatrixPrice value) => + new(value); - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `ReplacePricePriceMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum([NotNullWhen(true)] out ReplacePricePriceMinimum? value) - { - value = this.Value as ReplacePricePriceMinimum; - return value != null; - } + public static implicit operator ReplacePricePrice( + NewSubscriptionThresholdTotalAmountPrice value + ) => new(value); - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionMinimumComposite(out var value)) { - /// // `value` is of type `NewSubscriptionMinimumCompositePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMinimumComposite( - [NotNullWhen(true)] out NewSubscriptionMinimumCompositePrice? value - ) - { - value = this.Value as NewSubscriptionMinimumCompositePrice; - return value != null; - } + public static implicit operator ReplacePricePrice(NewSubscriptionTieredPackagePrice value) => + new(value); - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickPercent(out var value)) { - /// // `value` is of type `ReplacePricePricePercent` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickPercent([NotNullWhen(true)] out ReplacePricePricePercent? value) - { - value = this.Value as ReplacePricePricePercent; - return value != null; - } + public static implicit operator ReplacePricePrice( + NewSubscriptionTieredWithMinimumPrice value + ) => new(value); - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickEventOutput(out var value)) { - /// // `value` is of type `ReplacePricePriceEventOutput` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickEventOutput([NotNullWhen(true)] out ReplacePricePriceEventOutput? value) - { - value = this.Value as ReplacePricePriceEventOutput; - return value != null; - } + public static implicit operator ReplacePricePrice(NewSubscriptionGroupedTieredPrice value) => + new(value); + + public static implicit operator ReplacePricePrice( + NewSubscriptionTieredPackageWithMinimumPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + NewSubscriptionPackageWithAllocationPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice(NewSubscriptionUnitWithPercentPrice value) => + new(value); + + public static implicit operator ReplacePricePrice( + NewSubscriptionMatrixWithAllocationPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice(ReplacePricePriceTieredWithProration value) => + new(value); + + public static implicit operator ReplacePricePrice( + NewSubscriptionUnitWithProrationPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + NewSubscriptionGroupedAllocationPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + NewSubscriptionBulkWithProrationPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + NewSubscriptionGroupedWithProratedMinimumPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + NewSubscriptionGroupedWithMeteredMinimumPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + ReplacePricePriceGroupedWithMinMaxThresholds value + ) => new(value); + + public static implicit operator ReplacePricePrice( + NewSubscriptionMatrixWithDisplayNamePrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + NewSubscriptionGroupedTieredPackagePrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + NewSubscriptionMaxGroupTieredPackagePrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + NewSubscriptionScalableMatrixWithUnitPricingPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + NewSubscriptionScalableMatrixWithTieredPricingPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + NewSubscriptionCumulativeGroupedBulkPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + ReplacePricePriceCumulativeGroupedAllocation value + ) => new(value); + + public static implicit operator ReplacePricePrice(NewSubscriptionMinimumCompositePrice value) => + new(value); + + public static implicit operator ReplacePricePrice(ReplacePricePricePercent value) => new(value); + + public static implicit operator ReplacePricePrice(ReplacePricePriceEventOutput value) => + new(value); /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). /// /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). + /// Thrown when the instance does not pass validation. /// - /// - /// - /// - /// instance.Switch( - /// (NewSubscriptionUnitPrice value) => {...}, - /// (NewSubscriptionTieredPrice value) => {...}, - /// (NewSubscriptionBulkPrice value) => {...}, - /// (ReplacePricePriceBulkWithFilters value) => {...}, - /// (NewSubscriptionPackagePrice value) => {...}, - /// (NewSubscriptionMatrixPrice value) => {...}, - /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, - /// (NewSubscriptionTieredPackagePrice value) => {...}, - /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedTieredPrice value) => {...}, - /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, - /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, - /// (NewSubscriptionUnitWithPercentPrice value) => {...}, - /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, - /// (ReplacePricePriceTieredWithProration value) => {...}, - /// (NewSubscriptionUnitWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedAllocationPrice value) => {...}, - /// (NewSubscriptionBulkWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, - /// (ReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, - /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, - /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, - /// (ReplacePricePriceCumulativeGroupedAllocation value) => {...}, - /// (ReplacePricePriceMinimum value) => {...}, - /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (ReplacePricePricePercent value) => {...}, - /// (ReplacePricePriceEventOutput value) => {...} - /// ); - /// - /// /// - public void Switch( - System::Action newSubscriptionUnit, - System::Action newSubscriptionTiered, - System::Action newSubscriptionBulk, - System::Action bulkWithFilters, - System::Action newSubscriptionPackage, - System::Action newSubscriptionMatrix, - System::Action newSubscriptionThresholdTotalAmount, - System::Action newSubscriptionTieredPackage, - System::Action newSubscriptionTieredWithMinimum, - System::Action newSubscriptionGroupedTiered, - System::Action newSubscriptionTieredPackageWithMinimum, - System::Action newSubscriptionPackageWithAllocation, - System::Action newSubscriptionUnitWithPercent, - System::Action newSubscriptionMatrixWithAllocation, - System::Action tieredWithProration, - System::Action newSubscriptionUnitWithProration, - System::Action newSubscriptionGroupedAllocation, - System::Action newSubscriptionBulkWithProration, - System::Action newSubscriptionGroupedWithProratedMinimum, - System::Action newSubscriptionGroupedWithMeteredMinimum, - System::Action groupedWithMinMaxThresholds, - System::Action newSubscriptionMatrixWithDisplayName, - System::Action newSubscriptionGroupedTieredPackage, - System::Action newSubscriptionMaxGroupTieredPackage, - System::Action newSubscriptionScalableMatrixWithUnitPricing, - System::Action newSubscriptionScalableMatrixWithTieredPricing, - System::Action newSubscriptionCumulativeGroupedBulk, - System::Action cumulativeGroupedAllocation, - System::Action minimum, - System::Action newSubscriptionMinimumComposite, - System::Action percent, - System::Action eventOutput - ) + public override void Validate() { - switch (this.Value) + if (this.Value == null) { - case NewSubscriptionUnitPrice value: - newSubscriptionUnit(value); - break; - case NewSubscriptionTieredPrice value: - newSubscriptionTiered(value); - break; - case NewSubscriptionBulkPrice value: - newSubscriptionBulk(value); - break; - case ReplacePricePriceBulkWithFilters value: - bulkWithFilters(value); - break; - case NewSubscriptionPackagePrice value: - newSubscriptionPackage(value); - break; - case NewSubscriptionMatrixPrice value: - newSubscriptionMatrix(value); - break; - case NewSubscriptionThresholdTotalAmountPrice value: - newSubscriptionThresholdTotalAmount(value); - break; - case NewSubscriptionTieredPackagePrice value: - newSubscriptionTieredPackage(value); - break; - case NewSubscriptionTieredWithMinimumPrice value: - newSubscriptionTieredWithMinimum(value); - break; - case NewSubscriptionGroupedTieredPrice value: - newSubscriptionGroupedTiered(value); - break; - case NewSubscriptionTieredPackageWithMinimumPrice value: - newSubscriptionTieredPackageWithMinimum(value); - break; - case NewSubscriptionPackageWithAllocationPrice value: - newSubscriptionPackageWithAllocation(value); - break; - case NewSubscriptionUnitWithPercentPrice value: - newSubscriptionUnitWithPercent(value); - break; - case NewSubscriptionMatrixWithAllocationPrice value: - newSubscriptionMatrixWithAllocation(value); - break; - case ReplacePricePriceTieredWithProration value: - tieredWithProration(value); - break; - case NewSubscriptionUnitWithProrationPrice value: - newSubscriptionUnitWithProration(value); - break; - case NewSubscriptionGroupedAllocationPrice value: - newSubscriptionGroupedAllocation(value); - break; - case NewSubscriptionBulkWithProrationPrice value: - newSubscriptionBulkWithProration(value); - break; - case NewSubscriptionGroupedWithProratedMinimumPrice value: - newSubscriptionGroupedWithProratedMinimum(value); - break; - case NewSubscriptionGroupedWithMeteredMinimumPrice value: - newSubscriptionGroupedWithMeteredMinimum(value); - break; - case ReplacePricePriceGroupedWithMinMaxThresholds value: - groupedWithMinMaxThresholds(value); - break; - case NewSubscriptionMatrixWithDisplayNamePrice value: - newSubscriptionMatrixWithDisplayName(value); - break; - case NewSubscriptionGroupedTieredPackagePrice value: - newSubscriptionGroupedTieredPackage(value); - break; - case NewSubscriptionMaxGroupTieredPackagePrice value: - newSubscriptionMaxGroupTieredPackage(value); - break; - case NewSubscriptionScalableMatrixWithUnitPricingPrice value: - newSubscriptionScalableMatrixWithUnitPricing(value); - break; - case NewSubscriptionScalableMatrixWithTieredPricingPrice value: - newSubscriptionScalableMatrixWithTieredPricing(value); - break; - case NewSubscriptionCumulativeGroupedBulkPrice value: - newSubscriptionCumulativeGroupedBulk(value); - break; - case ReplacePricePriceCumulativeGroupedAllocation value: - cumulativeGroupedAllocation(value); - break; - case ReplacePricePriceMinimum value: - minimum(value); - break; - case NewSubscriptionMinimumCompositePrice value: - newSubscriptionMinimumComposite(value); - break; - case ReplacePricePricePercent value: - percent(value); - break; - case ReplacePricePriceEventOutput value: - eventOutput(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ); - } - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (NewSubscriptionUnitPrice value) => {...}, - /// (NewSubscriptionTieredPrice value) => {...}, - /// (NewSubscriptionBulkPrice value) => {...}, - /// (ReplacePricePriceBulkWithFilters value) => {...}, - /// (NewSubscriptionPackagePrice value) => {...}, - /// (NewSubscriptionMatrixPrice value) => {...}, - /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, - /// (NewSubscriptionTieredPackagePrice value) => {...}, - /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedTieredPrice value) => {...}, - /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, - /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, - /// (NewSubscriptionUnitWithPercentPrice value) => {...}, - /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, - /// (ReplacePricePriceTieredWithProration value) => {...}, - /// (NewSubscriptionUnitWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedAllocationPrice value) => {...}, - /// (NewSubscriptionBulkWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, - /// (ReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, - /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, - /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, - /// (ReplacePricePriceCumulativeGroupedAllocation value) => {...}, - /// (ReplacePricePriceMinimum value) => {...}, - /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (ReplacePricePricePercent value) => {...}, - /// (ReplacePricePriceEventOutput value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func newSubscriptionUnit, - System::Func newSubscriptionTiered, - System::Func newSubscriptionBulk, - System::Func bulkWithFilters, - System::Func newSubscriptionPackage, - System::Func newSubscriptionMatrix, - System::Func< - NewSubscriptionThresholdTotalAmountPrice, - T - > newSubscriptionThresholdTotalAmount, - System::Func newSubscriptionTieredPackage, - System::Func newSubscriptionTieredWithMinimum, - System::Func newSubscriptionGroupedTiered, - System::Func< - NewSubscriptionTieredPackageWithMinimumPrice, - T - > newSubscriptionTieredPackageWithMinimum, - System::Func< - NewSubscriptionPackageWithAllocationPrice, - T - > newSubscriptionPackageWithAllocation, - System::Func newSubscriptionUnitWithPercent, - System::Func< - NewSubscriptionMatrixWithAllocationPrice, - T - > newSubscriptionMatrixWithAllocation, - System::Func tieredWithProration, - System::Func newSubscriptionUnitWithProration, - System::Func newSubscriptionGroupedAllocation, - System::Func newSubscriptionBulkWithProration, - System::Func< - NewSubscriptionGroupedWithProratedMinimumPrice, - T - > newSubscriptionGroupedWithProratedMinimum, - System::Func< - NewSubscriptionGroupedWithMeteredMinimumPrice, - T - > newSubscriptionGroupedWithMeteredMinimum, - System::Func groupedWithMinMaxThresholds, - System::Func< - NewSubscriptionMatrixWithDisplayNamePrice, - T - > newSubscriptionMatrixWithDisplayName, - System::Func< - NewSubscriptionGroupedTieredPackagePrice, - T - > newSubscriptionGroupedTieredPackage, - System::Func< - NewSubscriptionMaxGroupTieredPackagePrice, - T - > newSubscriptionMaxGroupTieredPackage, - System::Func< - NewSubscriptionScalableMatrixWithUnitPricingPrice, - T - > newSubscriptionScalableMatrixWithUnitPricing, - System::Func< - NewSubscriptionScalableMatrixWithTieredPricingPrice, - T - > newSubscriptionScalableMatrixWithTieredPricing, - System::Func< - NewSubscriptionCumulativeGroupedBulkPrice, - T - > newSubscriptionCumulativeGroupedBulk, - System::Func cumulativeGroupedAllocation, - System::Func minimum, - System::Func newSubscriptionMinimumComposite, - System::Func percent, - System::Func eventOutput - ) - { - return this.Value switch - { - NewSubscriptionUnitPrice value => newSubscriptionUnit(value), - NewSubscriptionTieredPrice value => newSubscriptionTiered(value), - NewSubscriptionBulkPrice value => newSubscriptionBulk(value), - ReplacePricePriceBulkWithFilters value => bulkWithFilters(value), - NewSubscriptionPackagePrice value => newSubscriptionPackage(value), - NewSubscriptionMatrixPrice value => newSubscriptionMatrix(value), - NewSubscriptionThresholdTotalAmountPrice value => newSubscriptionThresholdTotalAmount( - value - ), - NewSubscriptionTieredPackagePrice value => newSubscriptionTieredPackage(value), - NewSubscriptionTieredWithMinimumPrice value => newSubscriptionTieredWithMinimum(value), - NewSubscriptionGroupedTieredPrice value => newSubscriptionGroupedTiered(value), - NewSubscriptionTieredPackageWithMinimumPrice value => - newSubscriptionTieredPackageWithMinimum(value), - NewSubscriptionPackageWithAllocationPrice value => newSubscriptionPackageWithAllocation( - value - ), - NewSubscriptionUnitWithPercentPrice value => newSubscriptionUnitWithPercent(value), - NewSubscriptionMatrixWithAllocationPrice value => newSubscriptionMatrixWithAllocation( - value - ), - ReplacePricePriceTieredWithProration value => tieredWithProration(value), - NewSubscriptionUnitWithProrationPrice value => newSubscriptionUnitWithProration(value), - NewSubscriptionGroupedAllocationPrice value => newSubscriptionGroupedAllocation(value), - NewSubscriptionBulkWithProrationPrice value => newSubscriptionBulkWithProration(value), - NewSubscriptionGroupedWithProratedMinimumPrice value => - newSubscriptionGroupedWithProratedMinimum(value), - NewSubscriptionGroupedWithMeteredMinimumPrice value => - newSubscriptionGroupedWithMeteredMinimum(value), - ReplacePricePriceGroupedWithMinMaxThresholds value => groupedWithMinMaxThresholds( - value - ), - NewSubscriptionMatrixWithDisplayNamePrice value => newSubscriptionMatrixWithDisplayName( - value - ), - NewSubscriptionGroupedTieredPackagePrice value => newSubscriptionGroupedTieredPackage( - value - ), - NewSubscriptionMaxGroupTieredPackagePrice value => newSubscriptionMaxGroupTieredPackage( - value - ), - NewSubscriptionScalableMatrixWithUnitPricingPrice value => - newSubscriptionScalableMatrixWithUnitPricing(value), - NewSubscriptionScalableMatrixWithTieredPricingPrice value => - newSubscriptionScalableMatrixWithTieredPricing(value), - NewSubscriptionCumulativeGroupedBulkPrice value => newSubscriptionCumulativeGroupedBulk( - value - ), - ReplacePricePriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation( - value - ), - ReplacePricePriceMinimum value => minimum(value), - NewSubscriptionMinimumCompositePrice value => newSubscriptionMinimumComposite(value), - ReplacePricePricePercent value => percent(value), - ReplacePricePriceEventOutput value => eventOutput(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ), - }; - } - - public static implicit operator ReplacePricePrice(NewSubscriptionUnitPrice value) => new(value); - - public static implicit operator ReplacePricePrice(NewSubscriptionTieredPrice value) => - new(value); - - public static implicit operator ReplacePricePrice(NewSubscriptionBulkPrice value) => new(value); - - public static implicit operator ReplacePricePrice(ReplacePricePriceBulkWithFilters value) => - new(value); - - public static implicit operator ReplacePricePrice(NewSubscriptionPackagePrice value) => - new(value); - - public static implicit operator ReplacePricePrice(NewSubscriptionMatrixPrice value) => - new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionThresholdTotalAmountPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice(NewSubscriptionTieredPackagePrice value) => - new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionTieredWithMinimumPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice(NewSubscriptionGroupedTieredPrice value) => - new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionTieredPackageWithMinimumPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionPackageWithAllocationPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice(NewSubscriptionUnitWithPercentPrice value) => - new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionMatrixWithAllocationPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice(ReplacePricePriceTieredWithProration value) => - new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionUnitWithProrationPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionGroupedAllocationPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionBulkWithProrationPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionGroupedWithProratedMinimumPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionGroupedWithMeteredMinimumPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - ReplacePricePriceGroupedWithMinMaxThresholds value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionMatrixWithDisplayNamePrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionGroupedTieredPackagePrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionMaxGroupTieredPackagePrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionScalableMatrixWithUnitPricingPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionScalableMatrixWithTieredPricingPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionCumulativeGroupedBulkPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - ReplacePricePriceCumulativeGroupedAllocation value - ) => new(value); - - public static implicit operator ReplacePricePrice(ReplacePricePriceMinimum value) => new(value); - - public static implicit operator ReplacePricePrice(NewSubscriptionMinimumCompositePrice value) => - new(value); - - public static implicit operator ReplacePricePrice(ReplacePricePricePercent value) => new(value); - - public static implicit operator ReplacePricePrice(ReplacePricePriceEventOutput value) => - new(value); - - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() - { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ); - } - this.Switch( - (newSubscriptionUnit) => newSubscriptionUnit.Validate(), - (newSubscriptionTiered) => newSubscriptionTiered.Validate(), - (newSubscriptionBulk) => newSubscriptionBulk.Validate(), - (bulkWithFilters) => bulkWithFilters.Validate(), - (newSubscriptionPackage) => newSubscriptionPackage.Validate(), - (newSubscriptionMatrix) => newSubscriptionMatrix.Validate(), - (newSubscriptionThresholdTotalAmount) => newSubscriptionThresholdTotalAmount.Validate(), - (newSubscriptionTieredPackage) => newSubscriptionTieredPackage.Validate(), - (newSubscriptionTieredWithMinimum) => newSubscriptionTieredWithMinimum.Validate(), - (newSubscriptionGroupedTiered) => newSubscriptionGroupedTiered.Validate(), - (newSubscriptionTieredPackageWithMinimum) => - newSubscriptionTieredPackageWithMinimum.Validate(), - (newSubscriptionPackageWithAllocation) => - newSubscriptionPackageWithAllocation.Validate(), - (newSubscriptionUnitWithPercent) => newSubscriptionUnitWithPercent.Validate(), - (newSubscriptionMatrixWithAllocation) => newSubscriptionMatrixWithAllocation.Validate(), - (tieredWithProration) => tieredWithProration.Validate(), - (newSubscriptionUnitWithProration) => newSubscriptionUnitWithProration.Validate(), - (newSubscriptionGroupedAllocation) => newSubscriptionGroupedAllocation.Validate(), - (newSubscriptionBulkWithProration) => newSubscriptionBulkWithProration.Validate(), - (newSubscriptionGroupedWithProratedMinimum) => - newSubscriptionGroupedWithProratedMinimum.Validate(), - (newSubscriptionGroupedWithMeteredMinimum) => - newSubscriptionGroupedWithMeteredMinimum.Validate(), - (groupedWithMinMaxThresholds) => groupedWithMinMaxThresholds.Validate(), - (newSubscriptionMatrixWithDisplayName) => - newSubscriptionMatrixWithDisplayName.Validate(), - (newSubscriptionGroupedTieredPackage) => newSubscriptionGroupedTieredPackage.Validate(), - (newSubscriptionMaxGroupTieredPackage) => - newSubscriptionMaxGroupTieredPackage.Validate(), - (newSubscriptionScalableMatrixWithUnitPricing) => - newSubscriptionScalableMatrixWithUnitPricing.Validate(), - (newSubscriptionScalableMatrixWithTieredPricing) => - newSubscriptionScalableMatrixWithTieredPricing.Validate(), - (newSubscriptionCumulativeGroupedBulk) => - newSubscriptionCumulativeGroupedBulk.Validate(), - (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), - (newSubscriptionMinimumComposite) => newSubscriptionMinimumComposite.Validate(), - (percent) => percent.Validate(), - (eventOutput) => eventOutput.Validate() - ); - } - - public virtual bool Equals(ReplacePricePrice? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } - - public override int GetHashCode() - { - return 0; - } - - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class ReplacePricePriceConverter : JsonConverter -{ - public override ReplacePricePrice? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - string? modelType; - try - { - modelType = element.GetProperty("model_type").GetString(); - } - catch - { - modelType = null; - } - - switch (modelType) - { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "bulk": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "bulk_with_filters": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "package": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "matrix": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "threshold_total_amount": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_package": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_with_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_tiered": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_package_with_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "package_with_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "unit_with_percent": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "matrix_with_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_with_proration": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "unit_with_proration": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "bulk_with_proration": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_prorated_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_metered_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_min_max_thresholds": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "matrix_with_display_name": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_tiered_package": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "max_group_tiered_package": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "scalable_matrix_with_unit_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "scalable_matrix_with_tiered_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "cumulative_grouped_bulk": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "cumulative_grouped_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum_composite": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "percent": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "event_output": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new ReplacePricePrice(element); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - ReplacePricePrice? value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value?.Json, options); - } -} - -[JsonConverter( - typeof(JsonModelConverter< - ReplacePricePriceBulkWithFilters, - ReplacePricePriceBulkWithFiltersFromRaw - >) -)] -public sealed record class ReplacePricePriceBulkWithFilters : JsonModel -{ - /// - /// Configuration for bulk_with_filters pricing - /// - public required ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "bulk_with_filters_config" - ); - } - init { this._rawData.Set("bulk_with_filters_config", value); } - } - - /// - /// The cadence to bill for this price on. - /// - public required ApiEnum Cadence - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); - } - init { this._rawData.Set("cadence", value); } - } - - /// - /// The id of the item the price will be associated with. - /// - public required string ItemID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); - } - init { this._rawData.Set("item_id", value); } - } - - /// - /// The pricing model type - /// - public JsonElement ModelType - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); - } - init { this._rawData.Set("model_type", value); } - } - - /// - /// The name of the price. - /// - public required string Name - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } - } - - /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. - /// - public string? BillableMetricID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); - } - init { this._rawData.Set("billable_metric_id", value); } - } - - /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. - /// - public bool? BilledInAdvance - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); - } - init { this._rawData.Set("billed_in_advance", value); } - } - - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } - } - - /// - /// The per unit conversion rate of the price currency to the invoicing currency. - /// - public double? ConversionRate - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); - } - init { this._rawData.Set("conversion_rate", value); } - } - - /// - /// The configuration for the rate of the price currency to the invoicing currency. - /// - public ReplacePricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", value); } - } - - /// - /// An ISO 4217 currency string, or custom pricing unit identifier, in which - /// this price is billed. - /// - public string? Currency - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("currency"); - } - init { this._rawData.Set("currency", value); } - } - - /// - /// For dimensional price: specifies a price group and dimension values - /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } - } - - /// - /// An alias for the price. - /// - public string? ExternalPriceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } - } - - /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. - /// - public double? FixedPriceQuantity - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } - } - - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", value); } - } - - /// - /// Within each billing cycle, specifies the cadence at which invoices are produced. - /// If unspecified, a single invoice is produced per billing cycle. - /// - public NewBillingCycleConfiguration? InvoicingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); - } - init { this._rawData.Set("invoicing_cycle_configuration", value); } - } - - /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared - /// by setting `metadata` to `null`. - /// - public IReadOnlyDictionary? Metadata - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) - ); - } - } - - /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. - /// - public string? ReferenceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("reference_id"); - } - init { this._rawData.Set("reference_id", value); } - } - - /// - public override void Validate() - { - this.BulkWithFiltersConfig.Validate(); - this.Cadence.Validate(); - _ = this.ItemID; - if ( - !JsonElement.DeepEquals( - this.ModelType, - JsonSerializer.SerializeToElement("bulk_with_filters") - ) - ) - { - throw new OrbInvalidDataException("Invalid value given for constant"); - } - _ = this.Name; - _ = this.BillableMetricID; - _ = this.BilledInAdvance; - this.BillingCycleConfiguration?.Validate(); - _ = this.ConversionRate; - this.ConversionRateConfig?.Validate(); - _ = this.Currency; - this.DimensionalPriceConfiguration?.Validate(); - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.InvoiceGroupingKey; - this.InvoicingCycleConfiguration?.Validate(); - _ = this.Metadata; - _ = this.ReferenceID; - } - - public ReplacePricePriceBulkWithFilters() - { - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - } - - public ReplacePricePriceBulkWithFilters( - ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters - ) - : base(replacePricePriceBulkWithFilters) { } - - public ReplacePricePriceBulkWithFilters(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceBulkWithFilters(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static ReplacePricePriceBulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class ReplacePricePriceBulkWithFiltersFromRaw : IFromRawJson -{ - /// - public ReplacePricePriceBulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFilters.FromRawUnchecked(rawData); -} - -/// -/// Configuration for bulk_with_filters pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw - >) -)] -public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig : JsonModel -{ - /// - /// Property filters to apply (all must match) - /// - public required IReadOnlyList Filters - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("filters"); - } - init - { - this._rawData.Set< - ImmutableArray - >("filters", ImmutableArray.ToImmutableArray(value)); - } - } - - /// - /// Bulk tiers for rating based on total usage volume - /// - public required IReadOnlyList Tiers - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); - } - init - { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); - } - } - - /// - public override void Validate() - { - foreach (var item in this.Filters) - { - item.Validate(); - } - foreach (var item in this.Tiers) - { - item.Validate(); - } - } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig - ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfig) { } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw - : IFromRawJson -{ - /// - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked(rawData); -} - -/// -/// Configuration for a single property filter -/// -[JsonConverter( - typeof(JsonModelConverter< - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter, - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw - >) -)] -public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter : JsonModel -{ - /// - /// Event property key to filter on - /// - public required string PropertyKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_key"); - } - init { this._rawData.Set("property_key", value); } - } - - /// - /// Event property value to match - /// - public required string PropertyValue - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_value"); + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePrice" + ); } - init { this._rawData.Set("property_value", value); } - } - - /// - public override void Validate() - { - _ = this.PropertyKey; - _ = this.PropertyValue; - } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); + this.Switch( + (newSubscriptionUnit) => newSubscriptionUnit.Validate(), + (newSubscriptionTiered) => newSubscriptionTiered.Validate(), + (newSubscriptionBulk) => newSubscriptionBulk.Validate(), + (bulkWithFilters) => bulkWithFilters.Validate(), + (newSubscriptionPackage) => newSubscriptionPackage.Validate(), + (newSubscriptionMatrix) => newSubscriptionMatrix.Validate(), + (newSubscriptionThresholdTotalAmount) => newSubscriptionThresholdTotalAmount.Validate(), + (newSubscriptionTieredPackage) => newSubscriptionTieredPackage.Validate(), + (newSubscriptionTieredWithMinimum) => newSubscriptionTieredWithMinimum.Validate(), + (newSubscriptionGroupedTiered) => newSubscriptionGroupedTiered.Validate(), + (newSubscriptionTieredPackageWithMinimum) => + newSubscriptionTieredPackageWithMinimum.Validate(), + (newSubscriptionPackageWithAllocation) => + newSubscriptionPackageWithAllocation.Validate(), + (newSubscriptionUnitWithPercent) => newSubscriptionUnitWithPercent.Validate(), + (newSubscriptionMatrixWithAllocation) => newSubscriptionMatrixWithAllocation.Validate(), + (tieredWithProration) => tieredWithProration.Validate(), + (newSubscriptionUnitWithProration) => newSubscriptionUnitWithProration.Validate(), + (newSubscriptionGroupedAllocation) => newSubscriptionGroupedAllocation.Validate(), + (newSubscriptionBulkWithProration) => newSubscriptionBulkWithProration.Validate(), + (newSubscriptionGroupedWithProratedMinimum) => + newSubscriptionGroupedWithProratedMinimum.Validate(), + (newSubscriptionGroupedWithMeteredMinimum) => + newSubscriptionGroupedWithMeteredMinimum.Validate(), + (groupedWithMinMaxThresholds) => groupedWithMinMaxThresholds.Validate(), + (newSubscriptionMatrixWithDisplayName) => + newSubscriptionMatrixWithDisplayName.Validate(), + (newSubscriptionGroupedTieredPackage) => newSubscriptionGroupedTieredPackage.Validate(), + (newSubscriptionMaxGroupTieredPackage) => + newSubscriptionMaxGroupTieredPackage.Validate(), + (newSubscriptionScalableMatrixWithUnitPricing) => + newSubscriptionScalableMatrixWithUnitPricing.Validate(), + (newSubscriptionScalableMatrixWithTieredPricing) => + newSubscriptionScalableMatrixWithTieredPricing.Validate(), + (newSubscriptionCumulativeGroupedBulk) => + newSubscriptionCumulativeGroupedBulk.Validate(), + (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), + (newSubscriptionMinimumComposite) => newSubscriptionMinimumComposite.Validate(), + (percent) => percent.Validate(), + (eventOutput) => eventOutput.Validate() + ); } -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - FrozenDictionary rawData - ) + public virtual bool Equals(ReplacePricePrice? other) { - this._rawData = new(rawData); + return other != null && JsonElement.DeepEquals(this.Json, other.Json); } -#pragma warning restore CS8618 - /// - public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( - IReadOnlyDictionary rawData - ) + public override int GetHashCode() { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + return 0; } -} -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw - : IFromRawJson -{ - /// - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( - IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked(rawData); + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -/// -/// Configuration for a single bulk pricing tier -/// -[JsonConverter( - typeof(JsonModelConverter< - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier, - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw - >) -)] -public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier : JsonModel +sealed class ReplacePricePriceConverter : JsonConverter { - /// - /// Amount per unit - /// - public required string UnitAmount + public override ReplacePricePrice? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) { - get + var element = JsonSerializer.Deserialize(ref reader, options); + string? modelType; + try { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + modelType = element.GetProperty("model_type").GetString(); } - init { this._rawData.Set("unit_amount", value); } - } - - /// - /// The lower bound for this tier - /// - public string? TierLowerBound - { - get + catch { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("tier_lower_bound"); + modelType = null; } - init { this._rawData.Set("tier_lower_bound", value); } - } - /// - public override void Validate() - { - _ = this.UnitAmount; - _ = this.TierLowerBound; - } + switch (modelType) + { + case "unit": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } + return new(element); + } + case "bulk": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } + return new(element); + } + case "bulk_with_filters": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 + return new(element); + } + case "package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } + return new(element); + } + case "matrix": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - [SetsRequiredMembers] - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier(string unitAmount) - : this() - { - this.UnitAmount = unitAmount; - } -} + return new(element); + } + case "threshold_total_amount": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw - : IFromRawJson -{ - /// - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked(rawData); -} + return new(element); + } + case "tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersCadenceConverter))] -public enum ReplacePricePriceBulkWithFiltersCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} + return new(element); + } + case "tiered_with_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -sealed class ReplacePricePriceBulkWithFiltersCadenceConverter - : JsonConverter -{ - public override ReplacePricePriceBulkWithFiltersCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => ReplacePricePriceBulkWithFiltersCadence.Annual, - "semi_annual" => ReplacePricePriceBulkWithFiltersCadence.SemiAnnual, - "monthly" => ReplacePricePriceBulkWithFiltersCadence.Monthly, - "quarterly" => ReplacePricePriceBulkWithFiltersCadence.Quarterly, - "one_time" => ReplacePricePriceBulkWithFiltersCadence.OneTime, - "custom" => ReplacePricePriceBulkWithFiltersCadence.Custom, - _ => (ReplacePricePriceBulkWithFiltersCadence)(-1), - }; - } + return new(element); + } + case "grouped_tiered": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public override void Write( - Utf8JsonWriter writer, - ReplacePricePriceBulkWithFiltersCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch + return new(element); + } + case "tiered_package_with_minimum": { - ReplacePricePriceBulkWithFiltersCadence.Annual => "annual", - ReplacePricePriceBulkWithFiltersCadence.SemiAnnual => "semi_annual", - ReplacePricePriceBulkWithFiltersCadence.Monthly => "monthly", - ReplacePricePriceBulkWithFiltersCadence.Quarterly => "quarterly", - ReplacePricePriceBulkWithFiltersCadence.OneTime => "one_time", - ReplacePricePriceBulkWithFiltersCadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } + + return new(element); + } + case "package_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersConversionRateConfigConverter))] -public record class ReplacePricePriceBulkWithFiltersConversionRateConfig : ModelBase -{ - public object? Value { get; } = null; + return new(element); + } + case "unit_with_percent": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - JsonElement? _element = null; + return new(element); + } + case "matrix_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public JsonElement Json - { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } - } + return new(element); + } + case "tiered_with_proration": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + return new(element); + } + case "unit_with_proration": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + return new(element); + } + case "grouped_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) - { - this._element = element; - } + return new(element); + } + case "bulk_with_proration": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) - { - value = this.Value as SharedUnitConversionRateConfig; - return value != null; - } + return new(element); + } + case "grouped_with_prorated_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) - { - value = this.Value as SharedTieredConversionRateConfig; - return value != null; - } + return new(element); + } + case "grouped_with_metered_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action unit, - System::Action tiered - ) - { - switch (this.Value) - { - case SharedUnitConversionRateConfig value: - unit(value); - break; - case SharedTieredConversionRateConfig value: - tiered(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" - ); - } - } + return new(element); + } + case "grouped_with_min_max_thresholds": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func unit, - System::Func tiered - ) - { - return this.Value switch - { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" - ), - }; - } + return new(element); + } + case "matrix_with_display_name": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); + return new(element); + } + case "grouped_tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); + return new(element); + } + case "max_group_tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() - { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" - ); - } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); - } + return new(element); + } + case "scalable_matrix_with_unit_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public virtual bool Equals(ReplacePricePriceBulkWithFiltersConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + return new(element); + } + case "scalable_matrix_with_tiered_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public override int GetHashCode() - { - return 0; - } + return new(element); + } + case "cumulative_grouped_bulk": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} + return new(element); + } + case "cumulative_grouped_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -sealed class ReplacePricePriceBulkWithFiltersConversionRateConfigConverter - : JsonConverter -{ - public override ReplacePricePriceBulkWithFiltersConversionRateConfig? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; - try - { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); - } - catch - { - conversionRateType = null; - } + return new(element); + } + case "minimum_composite": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - switch (conversionRateType) - { - case "unit": + return new(element); + } + case "percent": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -14953,11 +12786,11 @@ JsonSerializerOptions options return new(element); } - case "tiered": + case "event_output": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -14977,39 +12810,54 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceBulkWithFiltersConversionRateConfig(element); + return new ReplacePricePrice(element); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceBulkWithFiltersConversionRateConfig value, + ReplacePricePrice? value, JsonSerializerOptions options ) { - JsonSerializer.Serialize(writer, value.Json, options); + JsonSerializer.Serialize(writer, value?.Json, options); } } [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceTieredWithProration, - ReplacePricePriceTieredWithProrationFromRaw + ReplacePricePriceBulkWithFilters, + ReplacePricePriceBulkWithFiltersFromRaw >) )] -public sealed record class ReplacePricePriceTieredWithProration : JsonModel +public sealed record class ReplacePricePriceBulkWithFilters : JsonModel { + /// + /// Configuration for bulk_with_filters pricing + /// + public required ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "bulk_with_filters_config" + ); + } + init { this._rawData.Set("bulk_with_filters_config", value); } + } + /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -15054,21 +12902,6 @@ public required string Name init { this._rawData.Set("name", value); } } - /// - /// Configuration for tiered_with_proration pricing - /// - public required ReplacePricePriceTieredWithProrationTieredWithProrationConfig TieredWithProrationConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "tiered_with_proration_config" - ); - } - init { this._rawData.Set("tiered_with_proration_config", value); } - } - /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -15128,12 +12961,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public ReplacePricePriceTieredWithProrationConversionRateConfig? ConversionRateConfig + public ReplacePricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -15262,19 +13095,19 @@ public string? ReferenceID /// public override void Validate() { + this.BulkWithFiltersConfig.Validate(); this.Cadence.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("tiered_with_proration") + JsonSerializer.SerializeToElement("bulk_with_filters") ) ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.TieredWithProrationConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -15290,33 +13123,138 @@ public override void Validate() _ = this.ReferenceID; } - public ReplacePricePriceTieredWithProration() + public ReplacePricePriceBulkWithFilters() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } - public ReplacePricePriceTieredWithProration( - ReplacePricePriceTieredWithProration replacePricePriceTieredWithProration + public ReplacePricePriceBulkWithFilters( + ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters + ) + : base(replacePricePriceBulkWithFilters) { } + + public ReplacePricePriceBulkWithFilters(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceBulkWithFilters(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePricePriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ReplacePricePriceBulkWithFiltersFromRaw : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFilters.FromRawUnchecked(rawData); +} + +/// +/// Configuration for bulk_with_filters pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + >) +)] +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig : JsonModel +{ + /// + /// Property filters to apply (all must match) + /// + public required IReadOnlyList Filters + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("filters"); + } + init + { + this._rawData.Set< + ImmutableArray + >("filters", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// Bulk tiers for rating based on total usage volume + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + public override void Validate() + { + foreach (var item in this.Filters) + { + item.Validate(); + } + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } + + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig + ) + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfig) { } + + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + IReadOnlyDictionary rawData ) - : base(replacePricePriceTieredWithProration) { } - - public ReplacePricePriceTieredWithProration(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProration(FrozenDictionary rawData) + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceTieredWithProration FromRawUnchecked( + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15324,124 +13262,67 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceTieredWithProrationFromRaw - : IFromRawJson +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + : IFromRawJson { /// - public ReplacePricePriceTieredWithProration FromRawUnchecked( + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceTieredWithProration.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(ReplacePricePriceTieredWithProrationCadenceConverter))] -public enum ReplacePricePriceTieredWithProrationCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class ReplacePricePriceTieredWithProrationCadenceConverter - : JsonConverter -{ - public override ReplacePricePriceTieredWithProrationCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => ReplacePricePriceTieredWithProrationCadence.Annual, - "semi_annual" => ReplacePricePriceTieredWithProrationCadence.SemiAnnual, - "monthly" => ReplacePricePriceTieredWithProrationCadence.Monthly, - "quarterly" => ReplacePricePriceTieredWithProrationCadence.Quarterly, - "one_time" => ReplacePricePriceTieredWithProrationCadence.OneTime, - "custom" => ReplacePricePriceTieredWithProrationCadence.Custom, - _ => (ReplacePricePriceTieredWithProrationCadence)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - ReplacePricePriceTieredWithProrationCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - ReplacePricePriceTieredWithProrationCadence.Annual => "annual", - ReplacePricePriceTieredWithProrationCadence.SemiAnnual => "semi_annual", - ReplacePricePriceTieredWithProrationCadence.Monthly => "monthly", - ReplacePricePriceTieredWithProrationCadence.Quarterly => "quarterly", - ReplacePricePriceTieredWithProrationCadence.OneTime => "one_time", - ReplacePricePriceTieredWithProrationCadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked(rawData); } /// -/// Configuration for tiered_with_proration pricing +/// Configuration for a single property filter /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceTieredWithProrationTieredWithProrationConfig, - ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw >) )] -public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfig : JsonModel +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter : JsonModel { /// - /// Tiers for rating based on total usage quantities into the specified tier - /// with proration + /// Event property key to filter on /// - public required IReadOnlyList Tiers + public required string PropertyKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + return this._rawData.GetNotNullClass("property_key"); } - init + init { this._rawData.Set("property_key", value); } + } + + /// + /// Event property value to match + /// + public required string PropertyValue + { + get { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("property_value"); } + init { this._rawData.Set("property_value", value); } } /// public override void Validate() { - foreach (var item in this.Tiers) - { - item.Validate(); - } + _ = this.PropertyKey; + _ = this.PropertyValue; } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig() { } + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( - ReplacePricePriceTieredWithProrationTieredWithProrationConfig replacePricePriceTieredWithProrationTieredWithProrationConfig + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter ) - : base(replacePricePriceTieredWithProrationTieredWithProrationConfig) { } + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( IReadOnlyDictionary rawData ) { @@ -15450,7 +13331,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( FrozenDictionary rawData ) { @@ -15458,86 +13339,76 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( - IReadOnlyList tiers - ) - : this() - { - this.Tiers = tiers; - } } -class ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw - : IFromRawJson +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + : IFromRawJson { /// - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked(rawData); + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked(rawData); } /// -/// Configuration for a single tiered with proration tier +/// Configuration for a single bulk pricing tier /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier, - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw >) )] -public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier - : JsonModel +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier : JsonModel { /// - /// Inclusive tier starting value + /// Amount per unit /// - public required string TierLowerBound + public required string UnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("unit_amount"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("unit_amount", value); } } /// - /// Amount per unit + /// The lower bound for this tier /// - public required string UnitAmount + public string? TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNullableClass("tier_lower_bound"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("tier_lower_bound", value); } } /// public override void Validate() { - _ = this.TierLowerBound; _ = this.UnitAmount; + _ = this.TierLowerBound; } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() { } + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier replacePricePriceTieredWithProrationTieredWithProrationConfigTier + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier ) - : base(replacePricePriceTieredWithProrationTieredWithProrationConfigTier) { } + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( IReadOnlyDictionary rawData ) { @@ -15546,7 +13417,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( FrozenDictionary rawData ) { @@ -15554,27 +13425,93 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } + + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier(string unitAmount) + : this() + { + this.UnitAmount = unitAmount; + } +} + +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersCadenceConverter))] +public enum ReplacePricePriceBulkWithFiltersCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePricePriceBulkWithFiltersCadenceConverter + : JsonConverter +{ + public override ReplacePricePriceBulkWithFiltersCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePricePriceBulkWithFiltersCadence.Annual, + "semi_annual" => ReplacePricePriceBulkWithFiltersCadence.SemiAnnual, + "monthly" => ReplacePricePriceBulkWithFiltersCadence.Monthly, + "quarterly" => ReplacePricePriceBulkWithFiltersCadence.Quarterly, + "one_time" => ReplacePricePriceBulkWithFiltersCadence.OneTime, + "custom" => ReplacePricePriceBulkWithFiltersCadence.Custom, + _ => (ReplacePricePriceBulkWithFiltersCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePricePriceBulkWithFiltersCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePricePriceBulkWithFiltersCadence.Annual => "annual", + ReplacePricePriceBulkWithFiltersCadence.SemiAnnual => "semi_annual", + ReplacePricePriceBulkWithFiltersCadence.Monthly => "monthly", + ReplacePricePriceBulkWithFiltersCadence.Quarterly => "quarterly", + ReplacePricePriceBulkWithFiltersCadence.OneTime => "one_time", + ReplacePricePriceBulkWithFiltersCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } } -class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw - : IFromRawJson -{ - /// - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked(rawData); -} - -[JsonConverter(typeof(ReplacePricePriceTieredWithProrationConversionRateConfigConverter))] -public record class ReplacePricePriceTieredWithProrationConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersConversionRateConfigConverter))] +public record class ReplacePricePriceBulkWithFiltersConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -15591,7 +13528,7 @@ public JsonElement Json } } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15600,7 +13537,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15609,7 +13546,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) + public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) { this._element = element; } @@ -15691,7 +13628,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" ); } } @@ -15727,16 +13664,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -15755,13 +13692,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ReplacePricePriceTieredWithProrationConversionRateConfig? other) + public virtual bool Equals(ReplacePricePriceBulkWithFiltersConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -15775,10 +13712,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class ReplacePricePriceTieredWithProrationConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceBulkWithFiltersConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceTieredWithProrationConversionRateConfig? Read( + public override ReplacePricePriceBulkWithFiltersConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -15843,14 +13780,14 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceTieredWithProrationConversionRateConfig(element); + return new ReplacePricePriceBulkWithFiltersConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceTieredWithProrationConversionRateConfig value, + ReplacePricePriceBulkWithFiltersConversionRateConfig value, JsonSerializerOptions options ) { @@ -15860,42 +13797,27 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceGroupedWithMinMaxThresholds, - ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + ReplacePricePriceTieredWithProration, + ReplacePricePriceTieredWithProrationFromRaw >) )] -public sealed record class ReplacePricePriceGroupedWithMinMaxThresholds : JsonModel +public sealed record class ReplacePricePriceTieredWithProration : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } } - /// - /// Configuration for grouped_with_min_max_thresholds pricing - /// - public required ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_with_min_max_thresholds_config" - ); - } - init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } - } - /// /// The id of the item the price will be associated with. /// @@ -15935,6 +13857,21 @@ public required string Name init { this._rawData.Set("name", value); } } + /// + /// Configuration for tiered_with_proration pricing + /// + public required ReplacePricePriceTieredWithProrationTieredWithProrationConfig TieredWithProrationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "tiered_with_proration_config" + ); + } + init { this._rawData.Set("tiered_with_proration_config", value); } + } + /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -15994,12 +13931,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + public ReplacePricePriceTieredWithProrationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -16129,18 +14066,18 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.GroupedWithMinMaxThresholdsConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + JsonSerializer.SerializeToElement("tiered_with_proration") ) ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; + this.TieredWithProrationConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -16156,35 +14093,33 @@ public override void Validate() _ = this.ReferenceID; } - public ReplacePricePriceGroupedWithMinMaxThresholds() + public ReplacePricePriceTieredWithProration() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } - public ReplacePricePriceGroupedWithMinMaxThresholds( - ReplacePricePriceGroupedWithMinMaxThresholds replacePricePriceGroupedWithMinMaxThresholds + public ReplacePricePriceTieredWithProration( + ReplacePricePriceTieredWithProration replacePricePriceTieredWithProration ) - : base(replacePricePriceGroupedWithMinMaxThresholds) { } + : base(replacePricePriceTieredWithProration) { } - public ReplacePricePriceGroupedWithMinMaxThresholds( - IReadOnlyDictionary rawData - ) + public ReplacePricePriceTieredWithProration(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholds(FrozenDictionary rawData) + ReplacePricePriceTieredWithProration(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16192,20 +14127,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class ReplacePricePriceTieredWithProrationFromRaw + : IFromRawJson { /// - public ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + public ReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + ) => ReplacePricePriceTieredWithProration.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter))] -public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(ReplacePricePriceTieredWithProrationCadenceConverter))] +public enum ReplacePricePriceTieredWithProrationCadence { Annual, SemiAnnual, @@ -16215,10 +14150,10 @@ public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence Custom, } -sealed class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class ReplacePricePriceTieredWithProrationCadenceConverter + : JsonConverter { - public override ReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( + public override ReplacePricePriceTieredWithProrationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16226,122 +14161,186 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - "semi_annual" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual, - "monthly" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly, - "quarterly" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly, - "one_time" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime, - "custom" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom, - _ => (ReplacePricePriceGroupedWithMinMaxThresholdsCadence)(-1), + "annual" => ReplacePricePriceTieredWithProrationCadence.Annual, + "semi_annual" => ReplacePricePriceTieredWithProrationCadence.SemiAnnual, + "monthly" => ReplacePricePriceTieredWithProrationCadence.Monthly, + "quarterly" => ReplacePricePriceTieredWithProrationCadence.Quarterly, + "one_time" => ReplacePricePriceTieredWithProrationCadence.OneTime, + "custom" => ReplacePricePriceTieredWithProrationCadence.Custom, + _ => (ReplacePricePriceTieredWithProrationCadence)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - ReplacePricePriceGroupedWithMinMaxThresholdsCadence value, - JsonSerializerOptions options + public override void Write( + Utf8JsonWriter writer, + ReplacePricePriceTieredWithProrationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + ReplacePricePriceTieredWithProrationCadence.Annual => "annual", + ReplacePricePriceTieredWithProrationCadence.SemiAnnual => "semi_annual", + ReplacePricePriceTieredWithProrationCadence.Monthly => "monthly", + ReplacePricePriceTieredWithProrationCadence.Quarterly => "quarterly", + ReplacePricePriceTieredWithProrationCadence.OneTime => "one_time", + ReplacePricePriceTieredWithProrationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for tiered_with_proration pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceTieredWithProrationTieredWithProrationConfig, + ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw + >) +)] +public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfig : JsonModel +{ + /// + /// Tiers for rating based on total usage quantities into the specified tier + /// with proration + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + public override void Validate() + { + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig() { } + + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + ReplacePricePriceTieredWithProrationTieredWithProrationConfig replacePricePriceTieredWithProrationTieredWithProrationConfig + ) + : base(replacePricePriceTieredWithProrationTieredWithProrationConfig) { } + + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyList tiers ) + : this() { - JsonSerializer.Serialize( - writer, - value switch - { - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual => "annual", - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly => "monthly", - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime => "one_time", - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); + this.Tiers = tiers; } } +class ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked(rawData); +} + /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for a single tiered with proration tier /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier, + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw >) )] -public sealed record class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig +public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier : JsonModel { /// - /// The event property used to group before applying thresholds - /// - public required string GroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); - } - init { this._rawData.Set("grouping_key", value); } - } - - /// - /// The maximum amount to charge each group - /// - public required string MaximumCharge - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); - } - init { this._rawData.Set("maximum_charge", value); } - } - - /// - /// The minimum amount to charge each group, regardless of usage + /// Inclusive tier starting value /// - public required string MinimumCharge + public required string TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullClass("tier_lower_bound"); } - init { this._rawData.Set("minimum_charge", value); } + init { this._rawData.Set("tier_lower_bound", value); } } /// - /// The base price charged per group + /// Amount per unit /// - public required string PerUnitRate + public required string UnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("per_unit_rate"); + return this._rawData.GetNotNullClass("unit_amount"); } - init { this._rawData.Set("per_unit_rate", value); } + init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + _ = this.TierLowerBound; + _ = this.UnitAmount; } - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() { } - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier replacePricePriceTieredWithProrationTieredWithProrationConfigTier ) - : base(replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } + : base(replacePricePriceTieredWithProrationTieredWithProrationConfigTier) { } - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( IReadOnlyDictionary rawData ) { @@ -16350,7 +14349,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( FrozenDictionary rawData ) { @@ -16358,8 +14357,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16367,20 +14366,18 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + : IFromRawJson { /// - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) => - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( - rawData - ); + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked(rawData); } -[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter))] -public record class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceTieredWithProrationConversionRateConfigConverter))] +public record class ReplacePricePriceTieredWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -16397,7 +14394,7 @@ public JsonElement Json } } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16406,7 +14403,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16415,7 +14412,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -16497,7 +14494,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" ); } } @@ -16533,16 +14530,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -16561,15 +14558,13 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other - ) + public virtual bool Equals(ReplacePricePriceTieredWithProrationConversionRateConfig? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -16583,10 +14578,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceTieredWithProrationConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override ReplacePricePriceTieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16651,16 +14646,14 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( - element - ); + return new ReplacePricePriceTieredWithProrationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, + ReplacePricePriceTieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -16670,40 +14663,40 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceCumulativeGroupedAllocation, - ReplacePricePriceCumulativeGroupedAllocationFromRaw + ReplacePricePriceGroupedWithMinMaxThresholds, + ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw >) )] -public sealed record class ReplacePricePriceCumulativeGroupedAllocation : JsonModel +public sealed record class ReplacePricePriceGroupedWithMinMaxThresholds : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } } /// - /// Configuration for cumulative_grouped_allocation pricing + /// Configuration for grouped_with_min_max_thresholds pricing /// - public required ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "cumulative_grouped_allocation_config" + return this._rawData.GetNotNullClass( + "grouped_with_min_max_thresholds_config" ); } - init { this._rawData.Set("cumulative_grouped_allocation_config", value); } + init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } } /// @@ -16804,12 +14797,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -16939,12 +14932,12 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.CumulativeGroupedAllocationConfig.Validate(); + this.GroupedWithMinMaxThresholdsConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") ) ) { @@ -16966,35 +14959,35 @@ public override void Validate() _ = this.ReferenceID; } - public ReplacePricePriceCumulativeGroupedAllocation() + public ReplacePricePriceGroupedWithMinMaxThresholds() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } - public ReplacePricePriceCumulativeGroupedAllocation( - ReplacePricePriceCumulativeGroupedAllocation replacePricePriceCumulativeGroupedAllocation + public ReplacePricePriceGroupedWithMinMaxThresholds( + ReplacePricePriceGroupedWithMinMaxThresholds replacePricePriceGroupedWithMinMaxThresholds ) - : base(replacePricePriceCumulativeGroupedAllocation) { } + : base(replacePricePriceGroupedWithMinMaxThresholds) { } - public ReplacePricePriceCumulativeGroupedAllocation( + public ReplacePricePriceGroupedWithMinMaxThresholds( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocation(FrozenDictionary rawData) + ReplacePricePriceGroupedWithMinMaxThresholds(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17002,20 +14995,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceCumulativeGroupedAllocationFromRaw - : IFromRawJson +class ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + : IFromRawJson { /// - public ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + public ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked(rawData); + ) => ReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationCadenceConverter))] -public enum ReplacePricePriceCumulativeGroupedAllocationCadence +[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter))] +public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence { Annual, SemiAnnual, @@ -17025,10 +15018,10 @@ public enum ReplacePricePriceCumulativeGroupedAllocationCadence Custom, } -sealed class ReplacePricePriceCumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter { - public override ReplacePricePriceCumulativeGroupedAllocationCadence Read( + public override ReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17036,19 +15029,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - "semi_annual" => ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual, - "monthly" => ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly, - "quarterly" => ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly, - "one_time" => ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime, - "custom" => ReplacePricePriceCumulativeGroupedAllocationCadence.Custom, - _ => (ReplacePricePriceCumulativeGroupedAllocationCadence)(-1), + "annual" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + "semi_annual" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual, + "monthly" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly, + "one_time" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime, + "custom" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom, + _ => (ReplacePricePriceGroupedWithMinMaxThresholdsCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceCumulativeGroupedAllocationCadence value, + ReplacePricePriceGroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -17056,12 +15049,12 @@ JsonSerializerOptions options writer, value switch { - ReplacePricePriceCumulativeGroupedAllocationCadence.Annual => "annual", - ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", - ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly => "monthly", - ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly => "quarterly", - ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime => "one_time", - ReplacePricePriceCumulativeGroupedAllocationCadence.Custom => "custom", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual => "annual", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly => "monthly", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime => "one_time", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -17072,86 +15065,86 @@ JsonSerializerOptions options } /// -/// Configuration for cumulative_grouped_allocation pricing +/// Configuration for grouped_with_min_max_thresholds pricing /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw >) )] -public sealed record class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig +public sealed record class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig : JsonModel { /// - /// The overall allocation across all groups + /// The event property used to group before applying thresholds /// - public required string CumulativeAllocation + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("cumulative_allocation"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("cumulative_allocation", value); } + init { this._rawData.Set("grouping_key", value); } } /// - /// The allocation per individual group + /// The maximum amount to charge each group /// - public required string GroupAllocation + public required string MaximumCharge { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group_allocation"); + return this._rawData.GetNotNullClass("maximum_charge"); } - init { this._rawData.Set("group_allocation", value); } + init { this._rawData.Set("maximum_charge", value); } } /// - /// The event property used to group usage before applying allocations + /// The minimum amount to charge each group, regardless of usage /// - public required string GroupingKey + public required string MinimumCharge { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("minimum_charge"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("minimum_charge", value); } } /// - /// The amount to charge for each unit outside of the allocation + /// The base price charged per group /// - public required string UnitAmount + public required string PerUnitRate { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullClass("per_unit_rate"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("per_unit_rate", value); } } /// public override void Validate() { - _ = this.CumulativeAllocation; - _ = this.GroupAllocation; _ = this.GroupingKey; - _ = this.UnitAmount; + _ = this.MaximumCharge; + _ = this.MinimumCharge; + _ = this.PerUnitRate; } - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) - : base(replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } + : base(replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData ) { @@ -17160,7 +15153,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -17168,8 +15161,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17177,20 +15170,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + : IFromRawJson { /// - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( rawData ); } -[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter))] -public record class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter))] +public record class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -17207,7 +15200,7 @@ public JsonElement Json } } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17216,7 +15209,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -17225,7 +15218,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -17307,7 +15300,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } } @@ -17343,16 +15336,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -17371,14 +15364,14 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? other + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other ) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); @@ -17393,10 +15386,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( + public override ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17461,7 +15454,7 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( element ); } @@ -17470,7 +15463,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -17479,51 +15472,54 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter) + typeof(JsonModelConverter< + ReplacePricePriceCumulativeGroupedAllocation, + ReplacePricePriceCumulativeGroupedAllocationFromRaw + >) )] -public sealed record class ReplacePricePriceMinimum : JsonModel +public sealed record class ReplacePricePriceCumulativeGroupedAllocation : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( - "cadence" - ); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); } init { this._rawData.Set("cadence", value); } } /// - /// The id of the item the price will be associated with. + /// Configuration for cumulative_grouped_allocation pricing /// - public required string ItemID + public required ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass( + "cumulative_grouped_allocation_config" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("cumulative_grouped_allocation_config", value); } } /// - /// Configuration for minimum pricing + /// The id of the item the price will be associated with. /// - public required ReplacePricePriceMinimumMinimumConfig MinimumConfig + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" - ); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("minimum_config", value); } + init { this._rawData.Set("item_id", value); } } /// @@ -17611,12 +15607,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public ReplacePricePriceMinimumConversionRateConfig? ConversionRateConfig + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -17746,9 +15742,14 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); + this.CumulativeGroupedAllocationConfig.Validate(); _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -17768,31 +15769,35 @@ public override void Validate() _ = this.ReferenceID; } - public ReplacePricePriceMinimum() + public ReplacePricePriceCumulativeGroupedAllocation() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public ReplacePricePriceMinimum(ReplacePricePriceMinimum replacePricePriceMinimum) - : base(replacePricePriceMinimum) { } + public ReplacePricePriceCumulativeGroupedAllocation( + ReplacePricePriceCumulativeGroupedAllocation replacePricePriceCumulativeGroupedAllocation + ) + : base(replacePricePriceCumulativeGroupedAllocation) { } - public ReplacePricePriceMinimum(IReadOnlyDictionary rawData) + public ReplacePricePriceCumulativeGroupedAllocation( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceMinimum(FrozenDictionary rawData) + ReplacePricePriceCumulativeGroupedAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceMinimum FromRawUnchecked( + /// + public static ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17800,19 +15805,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceMinimumFromRaw : IFromRawJson +class ReplacePricePriceCumulativeGroupedAllocationFromRaw + : IFromRawJson { /// - public ReplacePricePriceMinimum FromRawUnchecked( + public ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceMinimum.FromRawUnchecked(rawData); + ) => ReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(ReplacePricePriceMinimumCadenceConverter))] -public enum ReplacePricePriceMinimumCadence +[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationCadenceConverter))] +public enum ReplacePricePriceCumulativeGroupedAllocationCadence { Annual, SemiAnnual, @@ -17822,10 +15828,10 @@ public enum ReplacePricePriceMinimumCadence Custom, } -sealed class ReplacePricePriceMinimumCadenceConverter - : JsonConverter +sealed class ReplacePricePriceCumulativeGroupedAllocationCadenceConverter + : JsonConverter { - public override ReplacePricePriceMinimumCadence Read( + public override ReplacePricePriceCumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17833,19 +15839,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => ReplacePricePriceMinimumCadence.Annual, - "semi_annual" => ReplacePricePriceMinimumCadence.SemiAnnual, - "monthly" => ReplacePricePriceMinimumCadence.Monthly, - "quarterly" => ReplacePricePriceMinimumCadence.Quarterly, - "one_time" => ReplacePricePriceMinimumCadence.OneTime, - "custom" => ReplacePricePriceMinimumCadence.Custom, - _ => (ReplacePricePriceMinimumCadence)(-1), + "annual" => ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + "semi_annual" => ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly, + "quarterly" => ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly, + "one_time" => ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime, + "custom" => ReplacePricePriceCumulativeGroupedAllocationCadence.Custom, + _ => (ReplacePricePriceCumulativeGroupedAllocationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceMinimumCadence value, + ReplacePricePriceCumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -17853,12 +15859,12 @@ JsonSerializerOptions options writer, value switch { - ReplacePricePriceMinimumCadence.Annual => "annual", - ReplacePricePriceMinimumCadence.SemiAnnual => "semi_annual", - ReplacePricePriceMinimumCadence.Monthly => "monthly", - ReplacePricePriceMinimumCadence.Quarterly => "quarterly", - ReplacePricePriceMinimumCadence.OneTime => "one_time", - ReplacePricePriceMinimumCadence.Custom => "custom", + ReplacePricePriceCumulativeGroupedAllocationCadence.Annual => "annual", + ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", + ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly => "monthly", + ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly => "quarterly", + ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime => "one_time", + ReplacePricePriceCumulativeGroupedAllocationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -17869,104 +15875,125 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for cumulative_grouped_allocation pricing /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceMinimumMinimumConfig, - ReplacePricePriceMinimumMinimumConfigFromRaw + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw >) )] -public sealed record class ReplacePricePriceMinimumMinimumConfig : JsonModel +public sealed record class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + : JsonModel { /// - /// The minimum amount to apply + /// The overall allocation across all groups /// - public required string MinimumAmount + public required string CumulativeAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNotNullClass("cumulative_allocation"); } - init { this._rawData.Set("minimum_amount", value); } + init { this._rawData.Set("cumulative_allocation", value); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// The allocation per individual group /// - public bool? Prorated + public required string GroupAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); + return this._rawData.GetNotNullClass("group_allocation"); } - init + init { this._rawData.Set("group_allocation", value); } + } + + /// + /// The event property used to group usage before applying allocations + /// + public required string GroupingKey + { + get { - if (value == null) - { - return; - } + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } - this._rawData.Set("prorated", value); + /// + /// The amount to charge for each unit outside of the allocation + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); } + init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.MinimumAmount; - _ = this.Prorated; + _ = this.CumulativeAllocation; + _ = this.GroupAllocation; + _ = this.GroupingKey; + _ = this.UnitAmount; } - public ReplacePricePriceMinimumMinimumConfig() { } + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } - public ReplacePricePriceMinimumMinimumConfig( - ReplacePricePriceMinimumMinimumConfig replacePricePriceMinimumMinimumConfig + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) - : base(replacePricePriceMinimumMinimumConfig) { } + : base(replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } - public ReplacePricePriceMinimumMinimumConfig(IReadOnlyDictionary rawData) + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceMinimumMinimumConfig(FrozenDictionary rawData) + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + /// + public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public ReplacePricePriceMinimumMinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class ReplacePricePriceMinimumMinimumConfigFromRaw - : IFromRawJson +class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + : IFromRawJson { /// - public ReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceMinimumMinimumConfig.FromRawUnchecked(rawData); + ) => + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( + rawData + ); } -[JsonConverter(typeof(ReplacePricePriceMinimumConversionRateConfigConverter))] -public record class ReplacePricePriceMinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter))] +public record class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -17983,7 +16010,7 @@ public JsonElement Json } } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17992,7 +16019,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -18001,7 +16028,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig(JsonElement element) + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -18083,7 +16110,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ); } } @@ -18119,16 +16146,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceMinimumConversionRateConfig( + public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceMinimumConversionRateConfig( + public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -18147,13 +16174,15 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ReplacePricePriceMinimumConversionRateConfig? other) + public virtual bool Equals( + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? other + ) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -18167,10 +16196,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class ReplacePricePriceMinimumConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceMinimumConversionRateConfig? Read( + public override ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -18235,14 +16264,16 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceMinimumConversionRateConfig(element); + return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + element + ); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceMinimumConversionRateConfig value, + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { diff --git a/src/Orb/Models/Subscriptions/SubscriptionFetchCostsParams.cs b/src/Orb/Models/Subscriptions/SubscriptionFetchCostsParams.cs index 5dfc7026..1677747e 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionFetchCostsParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionFetchCostsParams.cs @@ -20,8 +20,12 @@ namespace Orb.Models.Subscriptions; /// costs](fetch-customer-costs). Use this endpoint to limit your analysis of costs /// to a specific subscription for the customer (e.g. to de-aggregate costs when /// a customer's subscription has started and stopped on the same day). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionFetchCostsParams : ParamsBase +public record class SubscriptionFetchCostsParams : ParamsBase { public string? SubscriptionID { get; init; } @@ -81,11 +85,14 @@ public ApiEnum? ViewMode public SubscriptionFetchCostsParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionFetchCostsParams(SubscriptionFetchCostsParams subscriptionFetchCostsParams) : base(subscriptionFetchCostsParams) { this.SubscriptionID = subscriptionFetchCostsParams.SubscriptionID; } +#pragma warning restore CS8618 public SubscriptionFetchCostsParams( IReadOnlyDictionary rawHeaderData, @@ -120,6 +127,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["SubscriptionID"] = this.SubscriptionID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionFetchCostsParams? other) + { + if (other == null) + { + return false; + } + return (this.SubscriptionID?.Equals(other.SubscriptionID) ?? other.SubscriptionID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -139,6 +168,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// diff --git a/src/Orb/Models/Subscriptions/SubscriptionFetchParams.cs b/src/Orb/Models/Subscriptions/SubscriptionFetchParams.cs index 3a5ac6bd..8f7ea2ac 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionFetchParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionFetchParams.cs @@ -11,18 +11,25 @@ namespace Orb.Models.Subscriptions; /// /// This endpoint is used to fetch a [Subscription](/core-concepts##subscription) /// given an identifier. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionFetchParams : ParamsBase +public record class SubscriptionFetchParams : ParamsBase { public string? SubscriptionID { get; init; } public SubscriptionFetchParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionFetchParams(SubscriptionFetchParams subscriptionFetchParams) : base(subscriptionFetchParams) { this.SubscriptionID = subscriptionFetchParams.SubscriptionID; } +#pragma warning restore CS8618 public SubscriptionFetchParams( IReadOnlyDictionary rawHeaderData, @@ -57,6 +64,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["SubscriptionID"] = this.SubscriptionID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionFetchParams? other) + { + if (other == null) + { + return false; + } + return (this.SubscriptionID?.Equals(other.SubscriptionID) ?? other.SubscriptionID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -76,4 +105,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Subscriptions/SubscriptionFetchScheduleParams.cs b/src/Orb/Models/Subscriptions/SubscriptionFetchScheduleParams.cs index c273879a..a5e13cd2 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionFetchScheduleParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionFetchScheduleParams.cs @@ -12,8 +12,12 @@ namespace Orb.Models.Subscriptions; /// This endpoint returns a [paginated](/api-reference/pagination) list of all plans /// associated with a subscription along with their start and end dates. This list /// contains the subscription's initial plan along with past and future plan changes. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionFetchScheduleParams : ParamsBase +public record class SubscriptionFetchScheduleParams : ParamsBase { public string? SubscriptionID { get; init; } @@ -94,6 +98,8 @@ public DateTimeOffset? StartDateLte public SubscriptionFetchScheduleParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionFetchScheduleParams( SubscriptionFetchScheduleParams subscriptionFetchScheduleParams ) @@ -101,6 +107,7 @@ SubscriptionFetchScheduleParams subscriptionFetchScheduleParams { this.SubscriptionID = subscriptionFetchScheduleParams.SubscriptionID; } +#pragma warning restore CS8618 public SubscriptionFetchScheduleParams( IReadOnlyDictionary rawHeaderData, @@ -135,6 +142,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["SubscriptionID"] = this.SubscriptionID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionFetchScheduleParams? other) + { + if (other == null) + { + return false; + } + return (this.SubscriptionID?.Equals(other.SubscriptionID) ?? other.SubscriptionID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -154,4 +183,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Subscriptions/SubscriptionFetchUsageParams.cs b/src/Orb/Models/Subscriptions/SubscriptionFetchUsageParams.cs index 43e4d51f..7fdeb165 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionFetchUsageParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionFetchUsageParams.cs @@ -137,8 +137,12 @@ namespace Orb.Models.Subscriptions; /// /// - `first_dimension_key`: `region` - `first_dimension_value`: `us-east-1` /// - `second_dimension_key`: `provider` - `second_dimension_value`: `aws` +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionFetchUsageParams : ParamsBase +public record class SubscriptionFetchUsageParams : ParamsBase { public string? SubscriptionID { get; init; } @@ -268,11 +272,14 @@ public ApiEnum? ViewMode public SubscriptionFetchUsageParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionFetchUsageParams(SubscriptionFetchUsageParams subscriptionFetchUsageParams) : base(subscriptionFetchUsageParams) { this.SubscriptionID = subscriptionFetchUsageParams.SubscriptionID; } +#pragma warning restore CS8618 public SubscriptionFetchUsageParams( IReadOnlyDictionary rawHeaderData, @@ -307,6 +314,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["SubscriptionID"] = this.SubscriptionID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionFetchUsageParams? other) + { + if (other == null) + { + return false; + } + return (this.SubscriptionID?.Equals(other.SubscriptionID) ?? other.SubscriptionID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -326,6 +355,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// diff --git a/src/Orb/Models/Subscriptions/SubscriptionListParams.cs b/src/Orb/Models/Subscriptions/SubscriptionListParams.cs index e2d4fbec..66227c97 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionListParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionListParams.cs @@ -19,8 +19,12 @@ namespace Orb.Models.Subscriptions; /// Subscriptions can be filtered for a specific customer by using either the /// customer_id or external_customer_id query parameters. To filter subscriptions /// for multiple customers, use the customer_id[] or external_customer_id[] query parameters. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionListParams : ParamsBase +public record class SubscriptionListParams : ParamsBase { public System::DateTimeOffset? CreatedAtGt { @@ -151,22 +155,23 @@ public string? PlanID init { this._rawQueryData.Set("plan_id", value); } } - public ApiEnum? Status + public ApiEnum? Status { get { this._rawQueryData.Freeze(); - return this._rawQueryData.GetNullableClass< - ApiEnum - >("status"); + return this._rawQueryData.GetNullableClass>("status"); } init { this._rawQueryData.Set("status", value); } } public SubscriptionListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionListParams(SubscriptionListParams subscriptionListParams) : base(subscriptionListParams) { } +#pragma warning restore CS8618 public SubscriptionListParams( IReadOnlyDictionary rawHeaderData, @@ -201,6 +206,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/subscriptions") @@ -217,9 +242,14 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } -[JsonConverter(typeof(global::Orb.Models.Subscriptions.StatusConverter))] +[JsonConverter(typeof(StatusConverter))] public enum Status { Active, @@ -227,9 +257,9 @@ public enum Status Upcoming, } -sealed class StatusConverter : JsonConverter +sealed class StatusConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.Status Read( + public override Status Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -237,26 +267,22 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "active" => global::Orb.Models.Subscriptions.Status.Active, - "ended" => global::Orb.Models.Subscriptions.Status.Ended, - "upcoming" => global::Orb.Models.Subscriptions.Status.Upcoming, - _ => (global::Orb.Models.Subscriptions.Status)(-1), + "active" => Status.Active, + "ended" => Status.Ended, + "upcoming" => Status.Upcoming, + _ => (Status)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.Status value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Subscriptions.Status.Active => "active", - global::Orb.Models.Subscriptions.Status.Ended => "ended", - global::Orb.Models.Subscriptions.Status.Upcoming => "upcoming", + Status.Active => "active", + Status.Ended => "ended", + Status.Upcoming => "upcoming", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs b/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs index e59a81ef..6571a67a 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs @@ -80,8 +80,12 @@ namespace Orb.Models.Subscriptions; /// list of transitions must be specified to add additional transitions. The existing /// list of transitions can be retrieved using the `fixed_fee_quantity_transitions` /// property on a subscription’s serialized price intervals. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionPriceIntervalsParams : ParamsBase +public record class SubscriptionPriceIntervalsParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -222,6 +226,8 @@ public IReadOnlyList? EditAdjustments public SubscriptionPriceIntervalsParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionPriceIntervalsParams( SubscriptionPriceIntervalsParams subscriptionPriceIntervalsParams ) @@ -231,6 +237,7 @@ SubscriptionPriceIntervalsParams subscriptionPriceIntervalsParams this._rawBodyData = new(subscriptionPriceIntervalsParams._rawBodyData); } +#pragma warning restore CS8618 public SubscriptionPriceIntervalsParams( IReadOnlyDictionary rawHeaderData, @@ -271,6 +278,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["SubscriptionID"] = this.SubscriptionID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionPriceIntervalsParams? other) + { + if (other == null) + { + return false; + } + return (this.SubscriptionID?.Equals(other.SubscriptionID) ?? other.SubscriptionID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -299,6 +330,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(JsonModelConverter))] @@ -349,18 +385,16 @@ public bool? CanDeferBilling /// /// A list of discounts to initialize on the price interval. /// - public IReadOnlyList? Discounts + public IReadOnlyList? Discounts { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct< - ImmutableArray - >("discounts"); + return this._rawData.GetNullableStruct>("discounts"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "discounts", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -412,18 +446,18 @@ public string? Filter /// /// A list of fixed fee quantity transitions to initialize on the price interval. /// - public IReadOnlyList? FixedFeeQuantityTransitions + public IReadOnlyList? FixedFeeQuantityTransitions { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct< - ImmutableArray - >("fixed_fee_quantity_transitions"); + return this._rawData.GetNullableStruct>( + "fixed_fee_quantity_transitions" + ); } init { - this._rawData.Set?>( + this._rawData.Set?>( "fixed_fee_quantity_transitions", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -1009,14 +1043,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Subscriptions.Discount(Amount value) => - new(value); + public static implicit operator Discount(Amount value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Discount(Percentage value) => - new(value); + public static implicit operator Discount(Percentage value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Discount(Usage value) => - new(value); + public static implicit operator Discount(Usage value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -1041,7 +1072,7 @@ public override void Validate() ); } - public virtual bool Equals(global::Orb.Models.Subscriptions.Discount? other) + public virtual bool Equals(Discount? other) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); } @@ -1055,9 +1086,9 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class DiscountConverter : JsonConverter +sealed class DiscountConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.Discount? Read( + public override Discount? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1135,16 +1166,12 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.Discount(element); + return new Discount(element); } } } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.Discount value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Discount value, JsonSerializerOptions options) { JsonSerializer.Serialize(writer, value.Json, options); } @@ -1636,10 +1663,7 @@ public override void Write(Utf8JsonWriter writer, EndDate? value, JsonSerializer } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.FixedFeeQuantityTransition, - global::Orb.Models.Subscriptions.FixedFeeQuantityTransitionFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class FixedFeeQuantityTransition : JsonModel { @@ -1678,9 +1702,7 @@ public override void Validate() public FixedFeeQuantityTransition() { } - public FixedFeeQuantityTransition( - global::Orb.Models.Subscriptions.FixedFeeQuantityTransition fixedFeeQuantityTransition - ) + public FixedFeeQuantityTransition(FixedFeeQuantityTransition fixedFeeQuantityTransition) : base(fixedFeeQuantityTransition) { } public FixedFeeQuantityTransition(IReadOnlyDictionary rawData) @@ -1696,8 +1718,8 @@ public FixedFeeQuantityTransition(IReadOnlyDictionary rawDa } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.FixedFeeQuantityTransition FromRawUnchecked( + /// + public static FixedFeeQuantityTransition FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -1705,13 +1727,12 @@ IReadOnlyDictionary rawData } } -class FixedFeeQuantityTransitionFromRaw - : IFromRawJson +class FixedFeeQuantityTransitionFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.FixedFeeQuantityTransition FromRawUnchecked( + public FixedFeeQuantityTransition FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.FixedFeeQuantityTransition.FromRawUnchecked(rawData); + ) => FixedFeeQuantityTransition.FromRawUnchecked(rawData); } /// @@ -1768,7 +1789,6 @@ public string Currency newFloatingScalableMatrixWithTieredPricing: (x) => x.Currency, newFloatingCumulativeGroupedBulk: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, newFloatingMinimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency @@ -1809,7 +1829,6 @@ public string ItemID newFloatingScalableMatrixWithTieredPricing: (x) => x.ItemID, newFloatingCumulativeGroupedBulk: (x) => x.ItemID, cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, newFloatingMinimumComposite: (x) => x.ItemID, percent: (x) => x.ItemID, eventOutput: (x) => x.ItemID @@ -1850,7 +1869,6 @@ public string Name newFloatingScalableMatrixWithTieredPricing: (x) => x.Name, newFloatingCumulativeGroupedBulk: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, newFloatingMinimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name @@ -1891,7 +1909,6 @@ public string? BillableMetricID newFloatingScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, newFloatingCumulativeGroupedBulk: (x) => x.BillableMetricID, cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, newFloatingMinimumComposite: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID @@ -1932,7 +1949,6 @@ public bool? BilledInAdvance newFloatingScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, newFloatingCumulativeGroupedBulk: (x) => x.BilledInAdvance, cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, newFloatingMinimumComposite: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance @@ -1973,7 +1989,6 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newFloatingScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, newFloatingCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, newFloatingMinimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration @@ -2014,7 +2029,6 @@ public double? ConversionRate newFloatingScalableMatrixWithTieredPricing: (x) => x.ConversionRate, newFloatingCumulativeGroupedBulk: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, newFloatingMinimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate @@ -2055,7 +2069,6 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration newFloatingScalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, newFloatingCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, newFloatingMinimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration @@ -2096,7 +2109,6 @@ public string? ExternalPriceID newFloatingScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, newFloatingCumulativeGroupedBulk: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, newFloatingMinimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID @@ -2137,7 +2149,6 @@ public double? FixedPriceQuantity newFloatingScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, newFloatingCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, newFloatingMinimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity @@ -2178,7 +2189,6 @@ public string? InvoiceGroupingKey newFloatingScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, newFloatingCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, newFloatingMinimumComposite: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey @@ -2219,7 +2229,6 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration newFloatingScalableMatrixWithTieredPricing: (x) => x.InvoicingCycleConfiguration, newFloatingCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, newFloatingMinimumComposite: (x) => x.InvoicingCycleConfiguration, percent: (x) => x.InvoicingCycleConfiguration, eventOutput: (x) => x.InvoicingCycleConfiguration @@ -2401,12 +2410,6 @@ public PriceModel(PriceModelCumulativeGroupedAllocation value, JsonElement? elem this._element = element; } - public PriceModel(PriceModelMinimum value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - public PriceModel(NewFloatingMinimumCompositePrice value, JsonElement? element = null) { this.Value = value; @@ -3062,27 +3065,6 @@ public bool TryPickCumulativeGroupedAllocation( return value != null; } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `PriceModelMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum([NotNullWhen(true)] out PriceModelMinimum? value) - { - value = this.Value as PriceModelMinimum; - return value != null; - } - /// /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . @@ -3190,7 +3172,6 @@ public bool TryPickEventOutput([NotNullWhen(true)] out PriceModelEventOutput? va /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, /// (PriceModelCumulativeGroupedAllocation value) => {...}, - /// (PriceModelMinimum value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, /// (PriceModelPercent value) => {...}, /// (PriceModelEventOutput value) => {...} @@ -3227,7 +3208,6 @@ public void Switch( System::Action newFloatingScalableMatrixWithTieredPricing, System::Action newFloatingCumulativeGroupedBulk, System::Action cumulativeGroupedAllocation, - System::Action minimum, System::Action newFloatingMinimumComposite, System::Action percent, System::Action eventOutput @@ -3319,9 +3299,6 @@ public void Switch( case PriceModelCumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case PriceModelMinimum value: - minimum(value); - break; case NewFloatingMinimumCompositePrice value: newFloatingMinimumComposite(value); break; @@ -3379,7 +3356,6 @@ public void Switch( /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, /// (PriceModelCumulativeGroupedAllocation value) => {...}, - /// (PriceModelMinimum value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, /// (PriceModelPercent value) => {...}, /// (PriceModelEventOutput value) => {...} @@ -3431,7 +3407,6 @@ public T Match( > newFloatingScalableMatrixWithTieredPricing, System::Func newFloatingCumulativeGroupedBulk, System::Func cumulativeGroupedAllocation, - System::Func minimum, System::Func newFloatingMinimumComposite, System::Func percent, System::Func eventOutput @@ -3474,7 +3449,6 @@ public T Match( newFloatingScalableMatrixWithTieredPricing(value), NewFloatingCumulativeGroupedBulkPrice value => newFloatingCumulativeGroupedBulk(value), PriceModelCumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - PriceModelMinimum value => minimum(value), NewFloatingMinimumCompositePrice value => newFloatingMinimumComposite(value), PriceModelPercent value => percent(value), PriceModelEventOutput value => eventOutput(value), @@ -3559,8 +3533,6 @@ public static implicit operator PriceModel(NewFloatingCumulativeGroupedBulkPrice public static implicit operator PriceModel(PriceModelCumulativeGroupedAllocation value) => new(value); - public static implicit operator PriceModel(PriceModelMinimum value) => new(value); - public static implicit operator PriceModel(NewFloatingMinimumCompositePrice value) => new(value); @@ -3617,7 +3589,6 @@ public override void Validate() newFloatingScalableMatrixWithTieredPricing.Validate(), (newFloatingCumulativeGroupedBulk) => newFloatingCumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), (newFloatingMinimumComposite) => newFloatingMinimumComposite.Validate(), (percent) => percent.Validate(), (eventOutput) => eventOutput.Validate() @@ -4294,28 +4265,6 @@ JsonSerializerOptions options return new(element); } - case "minimum": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } case "minimum_composite": { try @@ -6924,755 +6873,6 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class PriceModelMinimum : JsonModel -{ - /// - /// The cadence to bill for this price on. - /// - public required ApiEnum Cadence - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( - "cadence" - ); - } - init { this._rawData.Set("cadence", value); } - } - - /// - /// An ISO 4217 currency string for which this price is billed in. - /// - public required string Currency - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("currency"); - } - init { this._rawData.Set("currency", value); } - } - - /// - /// The id of the item the price will be associated with. - /// - public required string ItemID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); - } - init { this._rawData.Set("item_id", value); } - } - - /// - /// Configuration for minimum pricing - /// - public required PriceModelMinimumMinimumConfig MinimumConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_config"); - } - init { this._rawData.Set("minimum_config", value); } - } - - /// - /// The pricing model type - /// - public JsonElement ModelType - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); - } - init { this._rawData.Set("model_type", value); } - } - - /// - /// The name of the price. - /// - public required string Name - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } - } - - /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. - /// - public string? BillableMetricID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); - } - init { this._rawData.Set("billable_metric_id", value); } - } - - /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. - /// - public bool? BilledInAdvance - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); - } - init { this._rawData.Set("billed_in_advance", value); } - } - - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } - } - - /// - /// The per unit conversion rate of the price currency to the invoicing currency. - /// - public double? ConversionRate - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); - } - init { this._rawData.Set("conversion_rate", value); } - } - - /// - /// The configuration for the rate of the price currency to the invoicing currency. - /// - public PriceModelMinimumConversionRateConfig? ConversionRateConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", value); } - } - - /// - /// For dimensional price: specifies a price group and dimension values - /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } - } - - /// - /// An alias for the price. - /// - public string? ExternalPriceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } - } - - /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. - /// - public double? FixedPriceQuantity - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } - } - - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", value); } - } - - /// - /// Within each billing cycle, specifies the cadence at which invoices are produced. - /// If unspecified, a single invoice is produced per billing cycle. - /// - public NewBillingCycleConfiguration? InvoicingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); - } - init { this._rawData.Set("invoicing_cycle_configuration", value); } - } - - /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared - /// by setting `metadata` to `null`. - /// - public IReadOnlyDictionary? Metadata - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) - ); - } - } - - /// - public override void Validate() - { - this.Cadence.Validate(); - _ = this.Currency; - _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) - { - throw new OrbInvalidDataException("Invalid value given for constant"); - } - _ = this.Name; - _ = this.BillableMetricID; - _ = this.BilledInAdvance; - this.BillingCycleConfiguration?.Validate(); - _ = this.ConversionRate; - this.ConversionRateConfig?.Validate(); - this.DimensionalPriceConfiguration?.Validate(); - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.InvoiceGroupingKey; - this.InvoicingCycleConfiguration?.Validate(); - _ = this.Metadata; - } - - public PriceModelMinimum() - { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); - } - - public PriceModelMinimum(PriceModelMinimum priceModelMinimum) - : base(priceModelMinimum) { } - - public PriceModelMinimum(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("minimum"); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - PriceModelMinimum(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static PriceModelMinimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class PriceModelMinimumFromRaw : IFromRawJson -{ - /// - public PriceModelMinimum FromRawUnchecked(IReadOnlyDictionary rawData) => - PriceModelMinimum.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(PriceModelMinimumCadenceConverter))] -public enum PriceModelMinimumCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class PriceModelMinimumCadenceConverter : JsonConverter -{ - public override PriceModelMinimumCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => PriceModelMinimumCadence.Annual, - "semi_annual" => PriceModelMinimumCadence.SemiAnnual, - "monthly" => PriceModelMinimumCadence.Monthly, - "quarterly" => PriceModelMinimumCadence.Quarterly, - "one_time" => PriceModelMinimumCadence.OneTime, - "custom" => PriceModelMinimumCadence.Custom, - _ => (PriceModelMinimumCadence)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - PriceModelMinimumCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - PriceModelMinimumCadence.Annual => "annual", - PriceModelMinimumCadence.SemiAnnual => "semi_annual", - PriceModelMinimumCadence.Monthly => "monthly", - PriceModelMinimumCadence.Quarterly => "quarterly", - PriceModelMinimumCadence.OneTime => "one_time", - PriceModelMinimumCadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} - -/// -/// Configuration for minimum pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - PriceModelMinimumMinimumConfig, - PriceModelMinimumMinimumConfigFromRaw - >) -)] -public sealed record class PriceModelMinimumMinimumConfig : JsonModel -{ - /// - /// The minimum amount to apply - /// - public required string MinimumAmount - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); - } - init { this._rawData.Set("minimum_amount", value); } - } - - /// - /// If true, subtotals from this price are prorated based on the service period - /// - public bool? Prorated - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); - } - init - { - if (value == null) - { - return; - } - - this._rawData.Set("prorated", value); - } - } - - /// - public override void Validate() - { - _ = this.MinimumAmount; - _ = this.Prorated; - } - - public PriceModelMinimumMinimumConfig() { } - - public PriceModelMinimumMinimumConfig( - PriceModelMinimumMinimumConfig priceModelMinimumMinimumConfig - ) - : base(priceModelMinimumMinimumConfig) { } - - public PriceModelMinimumMinimumConfig(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - PriceModelMinimumMinimumConfig(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static PriceModelMinimumMinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public PriceModelMinimumMinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } -} - -class PriceModelMinimumMinimumConfigFromRaw : IFromRawJson -{ - /// - public PriceModelMinimumMinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => PriceModelMinimumMinimumConfig.FromRawUnchecked(rawData); -} - -[JsonConverter(typeof(PriceModelMinimumConversionRateConfigConverter))] -public record class PriceModelMinimumConversionRateConfig : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - - public JsonElement Json - { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } - } - - public PriceModelMinimumConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public PriceModelMinimumConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public PriceModelMinimumConversionRateConfig(JsonElement element) - { - this._element = element; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) - { - value = this.Value as SharedUnitConversionRateConfig; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) - { - value = this.Value as SharedTieredConversionRateConfig; - return value != null; - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action unit, - System::Action tiered - ) - { - switch (this.Value) - { - case SharedUnitConversionRateConfig value: - unit(value); - break; - case SharedTieredConversionRateConfig value: - tiered(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of PriceModelMinimumConversionRateConfig" - ); - } - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func unit, - System::Func tiered - ) - { - return this.Value switch - { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of PriceModelMinimumConversionRateConfig" - ), - }; - } - - public static implicit operator PriceModelMinimumConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); - - public static implicit operator PriceModelMinimumConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); - - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() - { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of PriceModelMinimumConversionRateConfig" - ); - } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); - } - - public virtual bool Equals(PriceModelMinimumConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } - - public override int GetHashCode() - { - return 0; - } - - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class PriceModelMinimumConversionRateConfigConverter - : JsonConverter -{ - public override PriceModelMinimumConversionRateConfig? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; - try - { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); - } - catch - { - conversionRateType = null; - } - - switch (conversionRateType) - { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new PriceModelMinimumConversionRateConfig(element); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - PriceModelMinimumConversionRateConfig value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } -} - [JsonConverter(typeof(JsonModelConverter))] public sealed record class PriceModelPercent : JsonModel { diff --git a/src/Orb/Models/Subscriptions/SubscriptionRedeemCouponParams.cs b/src/Orb/Models/Subscriptions/SubscriptionRedeemCouponParams.cs index 392cb3fd..3668dedc 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionRedeemCouponParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionRedeemCouponParams.cs @@ -13,8 +13,12 @@ namespace Orb.Models.Subscriptions; /// /// Redeem a coupon effective at a given time. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionRedeemCouponParams : ParamsBase +public record class SubscriptionRedeemCouponParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -93,6 +97,8 @@ public string? CouponRedemptionCode public SubscriptionRedeemCouponParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionRedeemCouponParams( SubscriptionRedeemCouponParams subscriptionRedeemCouponParams ) @@ -102,6 +108,7 @@ SubscriptionRedeemCouponParams subscriptionRedeemCouponParams this._rawBodyData = new(subscriptionRedeemCouponParams._rawBodyData); } +#pragma warning restore CS8618 public SubscriptionRedeemCouponParams( IReadOnlyDictionary rawHeaderData, @@ -142,6 +149,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["SubscriptionID"] = this.SubscriptionID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionRedeemCouponParams? other) + { + if (other == null) + { + return false; + } + return (this.SubscriptionID?.Equals(other.SubscriptionID) ?? other.SubscriptionID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -170,6 +201,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(ChangeOptionConverter))] diff --git a/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs b/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs index 262e9fe6..f1772868 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs @@ -169,8 +169,12 @@ namespace Orb.Models.Subscriptions; /// ## Prorations for in-advance fees By default, Orb calculates the prorated /// difference in any fixed fees when making a plan change, adjusting the customer /// balance as needed. For details on this behavior, see [Modifying subscriptions](/product-catalog/modifying-subscriptions#prorations-for-in-advance-fees). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionSchedulePlanChangeParams : ParamsBase +public record class SubscriptionSchedulePlanChangeParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -613,6 +617,8 @@ public IReadOnlyList? UsageCustomerIds public SubscriptionSchedulePlanChangeParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParams( SubscriptionSchedulePlanChangeParams subscriptionSchedulePlanChangeParams ) @@ -622,6 +628,7 @@ SubscriptionSchedulePlanChangeParams subscriptionSchedulePlanChangeParams this._rawBodyData = new(subscriptionSchedulePlanChangeParams._rawBodyData); } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParams( IReadOnlyDictionary rawHeaderData, @@ -662,6 +669,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["SubscriptionID"] = this.SubscriptionID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionSchedulePlanChangeParams? other) + { + if (other == null) + { + return false; + } + return (this.SubscriptionID?.Equals(other.SubscriptionID) ?? other.SubscriptionID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -690,6 +721,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsChangeOptionConverter))] @@ -1640,7 +1676,6 @@ public string ItemID newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ItemID, newSubscriptionCumulativeGroupedBulk: (x) => x.ItemID, cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, newSubscriptionMinimumComposite: (x) => x.ItemID, percent: (x) => x.ItemID, eventOutput: (x) => x.ItemID @@ -1681,7 +1716,6 @@ public string Name newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Name, newSubscriptionCumulativeGroupedBulk: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, newSubscriptionMinimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name @@ -1722,7 +1756,6 @@ public string? BillableMetricID newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, newSubscriptionCumulativeGroupedBulk: (x) => x.BillableMetricID, cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, newSubscriptionMinimumComposite: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID @@ -1763,7 +1796,6 @@ public bool? BilledInAdvance newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, newSubscriptionCumulativeGroupedBulk: (x) => x.BilledInAdvance, cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, newSubscriptionMinimumComposite: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance @@ -1804,7 +1836,6 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, newSubscriptionCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, newSubscriptionMinimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration @@ -1845,7 +1876,6 @@ public double? ConversionRate newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ConversionRate, newSubscriptionCumulativeGroupedBulk: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, newSubscriptionMinimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate @@ -1886,7 +1916,6 @@ public string? Currency newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Currency, newSubscriptionCumulativeGroupedBulk: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, newSubscriptionMinimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency @@ -1929,7 +1958,6 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration x.DimensionalPriceConfiguration, newSubscriptionCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, newSubscriptionMinimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration @@ -1970,7 +1998,6 @@ public string? ExternalPriceID newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, newSubscriptionCumulativeGroupedBulk: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, newSubscriptionMinimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID @@ -2011,7 +2038,6 @@ public double? FixedPriceQuantity newSubscriptionScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, newSubscriptionCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, newSubscriptionMinimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity @@ -2052,7 +2078,6 @@ public string? InvoiceGroupingKey newSubscriptionScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, newSubscriptionCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, newSubscriptionMinimumComposite: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey @@ -2094,7 +2119,6 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration x.InvoicingCycleConfiguration, newSubscriptionCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, newSubscriptionMinimumComposite: (x) => x.InvoicingCycleConfiguration, percent: (x) => x.InvoicingCycleConfiguration, eventOutput: (x) => x.InvoicingCycleConfiguration @@ -2135,7 +2159,6 @@ public string? ReferenceID newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ReferenceID, newSubscriptionCumulativeGroupedBulk: (x) => x.ReferenceID, cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, newSubscriptionMinimumComposite: (x) => x.ReferenceID, percent: (x) => x.ReferenceID, eventOutput: (x) => x.ReferenceID @@ -2395,15 +2418,6 @@ public SubscriptionSchedulePlanChangeParamsAddPricePrice( this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePrice( - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - public SubscriptionSchedulePlanChangeParamsAddPricePrice( NewSubscriptionMinimumCompositePrice value, JsonElement? element = null @@ -3084,29 +3098,6 @@ out SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation return value != null; } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum( - [NotNullWhen(true)] out SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum? value - ) - { - value = this.Value as SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum; - return value != null; - } - /// /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . @@ -3218,7 +3209,6 @@ public bool TryPickEventOutput( /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, /// (SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum value) => {...}, /// (NewSubscriptionMinimumCompositePrice value) => {...}, /// (SubscriptionSchedulePlanChangeParamsAddPricePricePercent value) => {...}, /// (SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput value) => {...} @@ -3255,7 +3245,6 @@ public void Switch( System::Action newSubscriptionScalableMatrixWithTieredPricing, System::Action newSubscriptionCumulativeGroupedBulk, System::Action cumulativeGroupedAllocation, - System::Action minimum, System::Action newSubscriptionMinimumComposite, System::Action percent, System::Action eventOutput @@ -3347,9 +3336,6 @@ public void Switch( case SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum value: - minimum(value); - break; case NewSubscriptionMinimumCompositePrice value: newSubscriptionMinimumComposite(value); break; @@ -3409,7 +3395,6 @@ public void Switch( /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, /// (SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum value) => {...}, /// (NewSubscriptionMinimumCompositePrice value) => {...}, /// (SubscriptionSchedulePlanChangeParamsAddPricePricePercent value) => {...}, /// (SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput value) => {...} @@ -3494,7 +3479,6 @@ public T Match( SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation, T > cumulativeGroupedAllocation, - System::Func minimum, System::Func newSubscriptionMinimumComposite, System::Func percent, System::Func eventOutput @@ -3553,7 +3537,6 @@ public T Match( ), SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum value => minimum(value), NewSubscriptionMinimumCompositePrice value => newSubscriptionMinimumComposite(value), SubscriptionSchedulePlanChangeParamsAddPricePricePercent value => percent(value), SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput value => eventOutput( @@ -3677,10 +3660,6 @@ public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePric SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePrice( - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum value - ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePrice( NewSubscriptionMinimumCompositePrice value ) => new(value); @@ -3749,7 +3728,6 @@ public override void Validate() (newSubscriptionCumulativeGroupedBulk) => newSubscriptionCumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), (newSubscriptionMinimumComposite) => newSubscriptionMinimumComposite.Validate(), (percent) => percent.Validate(), (eventOutput) => eventOutput.Validate() @@ -4431,29 +4409,6 @@ JsonSerializerOptions options return new(element); } - case "minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } case "minimum_composite": { try @@ -8179,25 +8134,25 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum, - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePricePercent, + SubscriptionSchedulePlanChangeParamsAddPricePricePercentFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum : JsonModel +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePricePercent : JsonModel { /// /// The cadence to bill for this price on. /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -8217,44 +8172,44 @@ public required string ItemID } /// - /// Configuration for minimum pricing + /// The pricing model type /// - public required SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig MinimumConfig + public JsonElement ModelType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" - ); + return this._rawData.GetNotNullStruct("model_type"); } - init { this._rawData.Set("minimum_config", value); } + init { this._rawData.Set("model_type", value); } } /// - /// The pricing model type + /// The name of the price. /// - public JsonElement ModelType + public required string Name { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); + return this._rawData.GetNotNullClass("name"); } - init { this._rawData.Set("model_type", value); } + init { this._rawData.Set("name", value); } } /// - /// The name of the price. + /// Configuration for percent pricing /// - public required string Name + public required SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig PercentConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); + return this._rawData.GetNotNullClass( + "percent_config" + ); } - init { this._rawData.Set("name", value); } + init { this._rawData.Set("percent_config", value); } } /// @@ -8316,12 +8271,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig? ConversionRateConfig + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8452,12 +8407,12 @@ public override void Validate() { this.Cadence.Validate(); _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("percent"))) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; + this.PercentConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -8473,28 +8428,28 @@ public override void Validate() _ = this.ReferenceID; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum() + public SubscriptionSchedulePlanChangeParamsAddPricePricePercent() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum( - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum subscriptionSchedulePlanChangeParamsAddPricePriceMinimum + public SubscriptionSchedulePlanChangeParamsAddPricePricePercent( + SubscriptionSchedulePlanChangeParamsAddPricePricePercent subscriptionSchedulePlanChangeParamsAddPricePricePercent ) - : base(subscriptionSchedulePlanChangeParamsAddPricePriceMinimum) { } + : base(subscriptionSchedulePlanChangeParamsAddPricePricePercent) { } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercent( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum( + SubscriptionSchedulePlanChangeParamsAddPricePricePercent( FrozenDictionary rawData ) { @@ -8502,8 +8457,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePricePercent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8511,20 +8466,20 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePricePercentFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercent FromRawUnchecked( IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum.FromRawUnchecked(rawData); + ) => SubscriptionSchedulePlanChangeParamsAddPricePricePercent.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadenceConverter))] -public enum SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence +[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceConverter))] +public enum SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence { Annual, SemiAnnual, @@ -8534,10 +8489,10 @@ public enum SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence Custom, } -sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadenceConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8545,21 +8500,21 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + "annual" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, "semi_annual" => - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.SemiAnnual, - "monthly" => SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Monthly, + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual, + "monthly" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly, "quarterly" => - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Quarterly, - "one_time" => SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.OneTime, - "custom" => SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Custom, - _ => (SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence)(-1), + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly, + "one_time" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime, + "custom" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom, + _ => (SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence value, + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence value, JsonSerializerOptions options ) { @@ -8567,16 +8522,16 @@ JsonSerializerOptions options writer, value switch { - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual => "annual", - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.SemiAnnual => + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual => "annual", + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual => "semi_annual", - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Monthly => + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly => "monthly", - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Quarterly => + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly => "quarterly", - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.OneTime => + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime => "one_time", - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Custom => "custom", + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -8587,66 +8542,44 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for percent pricing /// [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig, - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfigFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig, + SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfigFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig : JsonModel { /// - /// The minimum amount to apply - /// - public required string MinimumAmount - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); - } - init { this._rawData.Set("minimum_amount", value); } - } - - /// - /// If true, subtotals from this price are prorated based on the service period + /// What percent of the component subtotals to charge /// - public bool? Prorated + public required double Percent { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); - } - init - { - if (value == null) - { - return; - } - - this._rawData.Set("prorated", value); + return this._rawData.GetNotNullStruct("percent"); } + init { this._rawData.Set("percent", value); } } /// public override void Validate() { - _ = this.MinimumAmount; - _ = this.Prorated; + _ = this.Percent; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig() { } + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig() { } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig( - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig subscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( + SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig subscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig ) - : base(subscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig) { } + : base(subscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig) { } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( IReadOnlyDictionary rawData ) { @@ -8655,7 +8588,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig( + SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( FrozenDictionary rawData ) { @@ -8663,8 +8596,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8672,31 +8605,29 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig( - string minimumAmount - ) + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig(double percent) : this() { - this.MinimumAmount = minimumAmount; + this.Percent = percent; } } -class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfigFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfigFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig.FromRawUnchecked( rawData ); } [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfigConverter) + typeof(SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigConverter) )] -public record class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig +public record class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -8714,7 +8645,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8723,7 +8654,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateCon this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8732,7 +8663,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateCon this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( JsonElement element ) { @@ -8816,7 +8747,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig" ); } } @@ -8852,16 +8783,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -8880,14 +8811,14 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig? other + SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig? other ) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); @@ -8902,10 +8833,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfigConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8970,7 +8901,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( element ); } @@ -8979,7 +8910,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -8989,30 +8920,45 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePricePercent, - SubscriptionSchedulePlanChangeParamsAddPricePricePercentFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput, + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePricePercent : JsonModel +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput : JsonModel { /// /// The cadence to bill for this price on. /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } } + /// + /// Configuration for event_output pricing + /// + public required SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig EventOutputConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "event_output_config" + ); + } + init { this._rawData.Set("event_output_config", value); } + } + /// /// The id of the item the price will be associated with. /// @@ -9052,21 +8998,6 @@ public required string Name init { this._rawData.Set("name", value); } } - /// - /// Configuration for percent pricing - /// - public required SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig PercentConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "percent_config" - ); - } - init { this._rawData.Set("percent_config", value); } - } - /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -9126,12 +9057,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig? ConversionRateConfig + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -9261,13 +9192,18 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); + this.EventOutputConfig.Validate(); _ = this.ItemID; - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("percent"))) + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("event_output") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.PercentConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -9283,28 +9219,28 @@ public override void Validate() _ = this.ReferenceID; } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercent() + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() { - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("event_output"); } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercent( - SubscriptionSchedulePlanChangeParamsAddPricePricePercent subscriptionSchedulePlanChangeParamsAddPricePricePercent + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput subscriptionSchedulePlanChangeParamsAddPricePriceEventOutput ) - : base(subscriptionSchedulePlanChangeParamsAddPricePricePercent) { } + : base(subscriptionSchedulePlanChangeParamsAddPricePriceEventOutput) { } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercent( + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("event_output"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePricePercent( + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( FrozenDictionary rawData ) { @@ -9312,8 +9248,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePricePercent FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9321,20 +9257,22 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsAddPricePricePercentFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePricePercent FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput FromRawUnchecked( IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsAddPricePricePercent.FromRawUnchecked(rawData); + ) => SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceConverter))] -public enum SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence +[JsonConverter( + typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadenceConverter) +)] +public enum SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence { Annual, SemiAnnual, @@ -9344,10 +9282,10 @@ public enum SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence Custom, } -sealed class SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadenceConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9355,21 +9293,23 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + "annual" => SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, "semi_annual" => - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual, - "monthly" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly, + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual, + "monthly" => + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly, "quarterly" => - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly, - "one_time" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime, - "custom" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom, - _ => (SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence)(-1), + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly, + "one_time" => + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime, + "custom" => SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom, + _ => (SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence value, + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence value, JsonSerializerOptions options ) { @@ -9377,16 +9317,18 @@ JsonSerializerOptions options writer, value switch { - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual => "annual", - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual => + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual => + "annual", + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual => "semi_annual", - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly => + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly => "monthly", - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly => + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly => "quarterly", - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime => + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime => "one_time", - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom => "custom", + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom => + "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -9397,44 +9339,75 @@ JsonSerializerOptions options } /// -/// Configuration for percent pricing +/// Configuration for event_output pricing /// [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig, - SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfigFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig, + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfigFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig : JsonModel { /// - /// What percent of the component subtotals to charge + /// The key in the event data to extract the unit rate from. /// - public required double Percent + public required string UnitRatingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("percent"); + return this._rawData.GetNotNullClass("unit_rating_key"); } - init { this._rawData.Set("percent", value); } + init { this._rawData.Set("unit_rating_key", value); } + } + + /// + /// If provided, this amount will be used as the unit rate when an event does + /// not have a value for the `unit_rating_key`. If not provided, events missing + /// a unit rate will be ignored. + /// + public string? DefaultUnitRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("default_unit_rate"); + } + init { this._rawData.Set("default_unit_rate", value); } + } + + /// + /// An optional key in the event data to group by (e.g., event ID). All events + /// will also be grouped by their unit rate. + /// + public string? GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } } /// public override void Validate() { - _ = this.Percent; + _ = this.UnitRatingKey; + _ = this.DefaultUnitRate; + _ = this.GroupingKey; } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig() { } + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig() { } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( - SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig subscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig subscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig ) - : base(subscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig) { } + : base(subscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig) { } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( IReadOnlyDictionary rawData ) { @@ -9443,7 +9416,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( FrozenDictionary rawData ) { @@ -9451,8 +9424,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9460,29 +9433,31 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig(double percent) + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( + string unitRatingKey + ) : this() { - this.Percent = percent; + this.UnitRatingKey = unitRatingKey; } } -class SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfigFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfigFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig.FromRawUnchecked( rawData ); } [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigConverter) + typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigConverter) )] -public record class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig +public record class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -9500,7 +9475,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -9509,7 +9484,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateCon this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -9518,7 +9493,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateCon this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( JsonElement element ) { @@ -9602,7 +9577,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig" ); } } @@ -9638,16 +9613,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -9666,14 +9641,14 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig? other + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig? other ) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); @@ -9688,10 +9663,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9756,7 +9731,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( element ); } @@ -9765,7 +9740,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value, JsonSerializerOptions options ) { @@ -9773,329 +9748,275 @@ JsonSerializerOptions options } } +/// +/// Reset billing periods to be aligned with the plan change's effective date or start +/// of the month. Defaults to `unchanged` which keeps subscription's existing billing +/// cycle alignment. +/// +[JsonConverter(typeof(BillingCycleAlignmentConverter))] +public enum BillingCycleAlignment +{ + Unchanged, + PlanChangeDate, + StartOfMonth, +} + +sealed class BillingCycleAlignmentConverter : JsonConverter +{ + public override BillingCycleAlignment Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "unchanged" => BillingCycleAlignment.Unchanged, + "plan_change_date" => BillingCycleAlignment.PlanChangeDate, + "start_of_month" => BillingCycleAlignment.StartOfMonth, + _ => (BillingCycleAlignment)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + BillingCycleAlignment value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + BillingCycleAlignment.Unchanged => "unchanged", + BillingCycleAlignment.PlanChangeDate => "plan_change_date", + BillingCycleAlignment.StartOfMonth => "start_of_month", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput, - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputFromRaw + SubscriptionSchedulePlanChangeParamsRemoveAdjustment, + SubscriptionSchedulePlanChangeParamsRemoveAdjustmentFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput : JsonModel +public sealed record class SubscriptionSchedulePlanChangeParamsRemoveAdjustment : JsonModel { /// - /// The cadence to bill for this price on. + /// The id of the adjustment to remove on the subscription. /// - public required ApiEnum< - string, - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence - > Cadence + public required string AdjustmentID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass("adjustment_id"); } - init { this._rawData.Set("cadence", value); } + init { this._rawData.Set("adjustment_id", value); } } - /// - /// Configuration for event_output pricing - /// - public required SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig EventOutputConfig + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "event_output_config" - ); - } - init { this._rawData.Set("event_output_config", value); } + _ = this.AdjustmentID; } - /// - /// The id of the item the price will be associated with. - /// - public required string ItemID + public SubscriptionSchedulePlanChangeParamsRemoveAdjustment() { } + + public SubscriptionSchedulePlanChangeParamsRemoveAdjustment( + SubscriptionSchedulePlanChangeParamsRemoveAdjustment subscriptionSchedulePlanChangeParamsRemoveAdjustment + ) + : base(subscriptionSchedulePlanChangeParamsRemoveAdjustment) { } + + public SubscriptionSchedulePlanChangeParamsRemoveAdjustment( + IReadOnlyDictionary rawData + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); - } - init { this._rawData.Set("item_id", value); } + this._rawData = new(rawData); } - /// - /// The pricing model type - /// - public JsonElement ModelType +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsRemoveAdjustment( + FrozenDictionary rawData + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); - } - init { this._rawData.Set("model_type", value); } + this._rawData = new(rawData); } +#pragma warning restore CS8618 - /// - /// The name of the price. - /// - public required string Name + /// + public static SubscriptionSchedulePlanChangeParamsRemoveAdjustment FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. - /// - public string? BillableMetricID + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsRemoveAdjustment(string adjustmentID) + : this() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); - } - init { this._rawData.Set("billable_metric_id", value); } + this.AdjustmentID = adjustmentID; } +} + +class SubscriptionSchedulePlanChangeParamsRemoveAdjustmentFromRaw + : IFromRawJson +{ + /// + public SubscriptionSchedulePlanChangeParamsRemoveAdjustment FromRawUnchecked( + IReadOnlyDictionary rawData + ) => SubscriptionSchedulePlanChangeParamsRemoveAdjustment.FromRawUnchecked(rawData); +} +[JsonConverter( + typeof(JsonModelConverter< + SubscriptionSchedulePlanChangeParamsRemovePrice, + SubscriptionSchedulePlanChangeParamsRemovePriceFromRaw + >) +)] +public sealed record class SubscriptionSchedulePlanChangeParamsRemovePrice : JsonModel +{ /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. + /// The external price id of the price to remove on the subscription. /// - public bool? BilledInAdvance + public string? ExternalPriceID { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); + return this._rawData.GetNullableClass("external_price_id"); } - init { this._rawData.Set("billed_in_advance", value); } + init { this._rawData.Set("external_price_id", value); } } /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. + /// The id of the price to remove on the subscription. /// - public NewBillingCycleConfiguration? BillingCycleConfiguration + public string? PriceID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); + return this._rawData.GetNullableClass("price_id"); } - init { this._rawData.Set("billing_cycle_configuration", value); } + init { this._rawData.Set("price_id", value); } } - /// - /// The per unit conversion rate of the price currency to the invoicing currency. - /// - public double? ConversionRate + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); - } - init { this._rawData.Set("conversion_rate", value); } + _ = this.ExternalPriceID; + _ = this.PriceID; } - /// - /// The configuration for the rate of the price currency to the invoicing currency. - /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig? ConversionRateConfig + public SubscriptionSchedulePlanChangeParamsRemovePrice() { } + + public SubscriptionSchedulePlanChangeParamsRemovePrice( + SubscriptionSchedulePlanChangeParamsRemovePrice subscriptionSchedulePlanChangeParamsRemovePrice + ) + : base(subscriptionSchedulePlanChangeParamsRemovePrice) { } + + public SubscriptionSchedulePlanChangeParamsRemovePrice( + IReadOnlyDictionary rawData + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", value); } + this._rawData = new(rawData); } - /// - /// An ISO 4217 currency string, or custom pricing unit identifier, in which - /// this price is billed. - /// - public string? Currency +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsRemovePrice(FrozenDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("currency"); - } - init { this._rawData.Set("currency", value); } + this._rawData = new(rawData); } +#pragma warning restore CS8618 - /// - /// For dimensional price: specifies a price group and dimension values - /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + /// + public static SubscriptionSchedulePlanChangeParamsRemovePrice FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} + +class SubscriptionSchedulePlanChangeParamsRemovePriceFromRaw + : IFromRawJson +{ + /// + public SubscriptionSchedulePlanChangeParamsRemovePrice FromRawUnchecked( + IReadOnlyDictionary rawData + ) => SubscriptionSchedulePlanChangeParamsRemovePrice.FromRawUnchecked(rawData); +} +[JsonConverter( + typeof(JsonModelConverter< + SubscriptionSchedulePlanChangeParamsReplaceAdjustment, + SubscriptionSchedulePlanChangeParamsReplaceAdjustmentFromRaw + >) +)] +public sealed record class SubscriptionSchedulePlanChangeParamsReplaceAdjustment : JsonModel +{ /// - /// An alias for the price. + /// The definition of a new adjustment to create and add to the subscription. /// - public string? ExternalPriceID + public required SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment Adjustment { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); + return this._rawData.GetNotNullClass( + "adjustment" + ); } - init { this._rawData.Set("external_price_id", value); } + init { this._rawData.Set("adjustment", value); } } /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// The id of the adjustment on the plan to replace in the subscription. /// - public double? FixedPriceQuantity + public required string ReplacesAdjustmentID { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); + return this._rawData.GetNotNullClass("replaces_adjustment_id"); } - init { this._rawData.Set("fixed_price_quantity", value); } + init { this._rawData.Set("replaces_adjustment_id", value); } } - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", value); } + this.Adjustment.Validate(); + _ = this.ReplacesAdjustmentID; } - /// - /// Within each billing cycle, specifies the cadence at which invoices are produced. - /// If unspecified, a single invoice is produced per billing cycle. - /// - public NewBillingCycleConfiguration? InvoicingCycleConfiguration + public SubscriptionSchedulePlanChangeParamsReplaceAdjustment() { } + + public SubscriptionSchedulePlanChangeParamsReplaceAdjustment( + SubscriptionSchedulePlanChangeParamsReplaceAdjustment subscriptionSchedulePlanChangeParamsReplaceAdjustment + ) + : base(subscriptionSchedulePlanChangeParamsReplaceAdjustment) { } + + public SubscriptionSchedulePlanChangeParamsReplaceAdjustment( + IReadOnlyDictionary rawData + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); - } - init { this._rawData.Set("invoicing_cycle_configuration", value); } - } - - /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared - /// by setting `metadata` to `null`. - /// - public IReadOnlyDictionary? Metadata - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) - ); - } - } - - /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. - /// - public string? ReferenceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("reference_id"); - } - init { this._rawData.Set("reference_id", value); } - } - - /// - public override void Validate() - { - this.Cadence.Validate(); - this.EventOutputConfig.Validate(); - _ = this.ItemID; - if ( - !JsonElement.DeepEquals( - this.ModelType, - JsonSerializer.SerializeToElement("event_output") - ) - ) - { - throw new OrbInvalidDataException("Invalid value given for constant"); - } - _ = this.Name; - _ = this.BillableMetricID; - _ = this.BilledInAdvance; - this.BillingCycleConfiguration?.Validate(); - _ = this.ConversionRate; - this.ConversionRateConfig?.Validate(); - _ = this.Currency; - this.DimensionalPriceConfiguration?.Validate(); - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.InvoiceGroupingKey; - this.InvoicingCycleConfiguration?.Validate(); - _ = this.Metadata; - _ = this.ReferenceID; - } - - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() - { - this.ModelType = JsonSerializer.SerializeToElement("event_output"); - } - - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput subscriptionSchedulePlanChangeParamsAddPricePriceEventOutput - ) - : base(subscriptionSchedulePlanChangeParamsAddPricePriceEventOutput) { } - - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( + SubscriptionSchedulePlanChangeParamsReplaceAdjustment( FrozenDictionary rawData ) { @@ -10103,8 +10024,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplaceAdjustment FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -10112,288 +10033,216 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplaceAdjustment FromRawUnchecked( IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput.FromRawUnchecked(rawData); + ) => SubscriptionSchedulePlanChangeParamsReplaceAdjustment.FromRawUnchecked(rawData); } /// -/// The cadence to bill for this price on. +/// The definition of a new adjustment to create and add to the subscription. /// -[JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadenceConverter) -)] -public enum SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadenceConverter - : JsonConverter +[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentConverter))] +public record class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment : ModelBase { - public override SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - "semi_annual" => - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual, - "monthly" => - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly, - "quarterly" => - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly, - "one_time" => - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime, - "custom" => SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom, - _ => (SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence)(-1), - }; - } + public object? Value { get; } = null; - public override void Write( - Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual => - "annual", - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual => - "semi_annual", - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly => - "monthly", - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly => - "quarterly", - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime => - "one_time", - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom => - "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} + JsonElement? _element = null; -/// -/// Configuration for event_output pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig, - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfigFromRaw - >) -)] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig - : JsonModel -{ - /// - /// The key in the event data to extract the unit rate from. - /// - public required string UnitRatingKey + public JsonElement Json { get { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_rating_key"); + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); } - init { this._rawData.Set("unit_rating_key", value); } } - /// - /// If provided, this amount will be used as the unit rate when an event does - /// not have a value for the `unit_rating_key`. If not provided, events missing - /// a unit rate will be ignored. - /// - public string? DefaultUnitRate + public string? Currency { get { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("default_unit_rate"); + return Match( + newPercentageDiscount: (x) => x.Currency, + newUsageDiscount: (x) => x.Currency, + newAmountDiscount: (x) => x.Currency, + newMinimum: (x) => x.Currency, + newMaximum: (x) => x.Currency + ); } - init { this._rawData.Set("default_unit_rate", value); } } - /// - /// An optional key in the event data to group by (e.g., event ID). All events - /// will also be grouped by their unit rate. - /// - public string? GroupingKey + public bool? IsInvoiceLevel { get { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("grouping_key"); + return Match( + newPercentageDiscount: (x) => x.IsInvoiceLevel, + newUsageDiscount: (x) => x.IsInvoiceLevel, + newAmountDiscount: (x) => x.IsInvoiceLevel, + newMinimum: (x) => x.IsInvoiceLevel, + newMaximum: (x) => x.IsInvoiceLevel + ); } - init { this._rawData.Set("grouping_key", value); } } - /// - public override void Validate() + public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewPercentageDiscount value, + JsonElement? element = null + ) { - _ = this.UnitRatingKey; - _ = this.DefaultUnitRate; - _ = this.GroupingKey; + this.Value = value; + this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig() { } - - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig subscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewUsageDiscount value, + JsonElement? element = null ) - : base(subscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig) { } + { + this.Value = value; + this._element = element; + } - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( - IReadOnlyDictionary rawData + public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewAmountDiscount value, + JsonElement? element = null ) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData + public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewMinimum value, + JsonElement? element = null ) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this.Value = value; + this._element = element; } - [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( - string unitRatingKey + public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewMaximum value, + JsonElement? element = null ) - : this() { - this.UnitRatingKey = unitRatingKey; + this.Value = value; + this._element = element; } -} - -class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfigFromRaw - : IFromRawJson -{ - /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig.FromRawUnchecked( - rawData - ); -} - -[JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigConverter) -)] -public record class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig - : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - public JsonElement Json + public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment(JsonElement element) { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } + this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPercentageDiscount(out var value)) { + /// // `value` is of type `NewPercentageDiscount` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) { - this.Value = value; - this._element = element; + value = this.Value as NewPercentageDiscount; + return value != null; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewUsageDiscount(out var value)) { + /// // `value` is of type `NewUsageDiscount` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) { - this.Value = value; - this._element = element; + value = this.Value as NewUsageDiscount; + return value != null; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( - JsonElement element - ) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewAmountDiscount(out var value)) { + /// // `value` is of type `NewAmountDiscount` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) { - this._element = element; + value = this.Value as NewAmountDiscount; + return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` + /// if (instance.TryPickNewMinimum(out var value)) { + /// // `value` is of type `NewMinimum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? value) { - value = this.Value as SharedUnitConversionRateConfig; + value = this.Value as NewMinimum; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` + /// if (instance.TryPickNewMaximum(out var value)) { + /// // `value` is of type `NewMaximum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) { - value = this.Value as SharedTieredConversionRateConfig; + value = this.Value as NewMaximum; return value != null; } @@ -10411,28 +10260,43 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// /// public void Switch( - System::Action unit, - System::Action tiered + System::Action newPercentageDiscount, + System::Action newUsageDiscount, + System::Action newAmountDiscount, + System::Action newMinimum, + System::Action newMaximum ) { switch (this.Value) { - case SharedUnitConversionRateConfig value: - unit(value); + case NewPercentageDiscount value: + newPercentageDiscount(value); break; - case SharedTieredConversionRateConfig value: - tiered(value); + case NewUsageDiscount value: + newUsageDiscount(value); + break; + case NewAmountDiscount value: + newAmountDiscount(value); + break; + case NewMinimum value: + newMinimum(value); + break; + case NewMaximum value: + newMaximum(value); break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment" ); } } @@ -10452,33 +10316,54 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// /// public T Match( - System::Func unit, - System::Func tiered + System::Func newPercentageDiscount, + System::Func newUsageDiscount, + System::Func newAmountDiscount, + System::Func newMinimum, + System::Func newMaximum ) { return this.Value switch { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), + NewPercentageDiscount value => newPercentageDiscount(value), + NewUsageDiscount value => newUsageDiscount(value), + NewAmountDiscount value => newAmountDiscount(value), + NewMinimum value => newMinimum(value), + NewMaximum value => newMaximum(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( - SharedUnitConversionRateConfig value + public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewPercentageDiscount value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( - SharedTieredConversionRateConfig value + public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewUsageDiscount value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewAmountDiscount value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewMinimum value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewMaximum value ) => new(value); /// @@ -10496,14 +10381,20 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment" ); } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + this.Switch( + (newPercentageDiscount) => newPercentageDiscount.Validate(), + (newUsageDiscount) => newUsageDiscount.Validate(), + (newAmountDiscount) => newAmountDiscount.Validate(), + (newMinimum) => newMinimum.Validate(), + (newMaximum) => newMaximum.Validate() + ); } public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig? other + SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment? other ) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); @@ -10518,33 +10409,33 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options ) { var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; + string? adjustmentType; try { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); + adjustmentType = element.GetProperty("adjustment_type").GetString(); } catch { - conversionRateType = null; + adjustmentType = null; } - switch (conversionRateType) + switch (adjustmentType) { - case "unit": + case "percentage_discount": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -10562,11 +10453,33 @@ JsonSerializerOptions options return new(element); } - case "tiered": + case "usage_discount": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } + + return new(element); + } + case "amount_discount": + { + try + { + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -10584,18 +10497,54 @@ JsonSerializerOptions options return new(element); } + case "minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } + + return new(element); + } + case "maximum": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } + + return new(element); + } default: { - return new SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( - element - ); + return new SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment(element); } } } public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value, JsonSerializerOptions options ) { @@ -10603,144 +10552,63 @@ JsonSerializerOptions options } } -/// -/// Reset billing periods to be aligned with the plan change's effective date or start -/// of the month. Defaults to `unchanged` which keeps subscription's existing billing -/// cycle alignment. -/// -[JsonConverter(typeof(BillingCycleAlignmentConverter))] -public enum BillingCycleAlignment -{ - Unchanged, - PlanChangeDate, - StartOfMonth, -} - -sealed class BillingCycleAlignmentConverter : JsonConverter -{ - public override BillingCycleAlignment Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "unchanged" => BillingCycleAlignment.Unchanged, - "plan_change_date" => BillingCycleAlignment.PlanChangeDate, - "start_of_month" => BillingCycleAlignment.StartOfMonth, - _ => (BillingCycleAlignment)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - BillingCycleAlignment value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - BillingCycleAlignment.Unchanged => "unchanged", - BillingCycleAlignment.PlanChangeDate => "plan_change_date", - BillingCycleAlignment.StartOfMonth => "start_of_month", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} - [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsRemoveAdjustment, - SubscriptionSchedulePlanChangeParamsRemoveAdjustmentFromRaw + SubscriptionSchedulePlanChangeParamsReplacePrice, + SubscriptionSchedulePlanChangeParamsReplacePriceFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsRemoveAdjustment : JsonModel +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePrice : JsonModel { /// - /// The id of the adjustment to remove on the subscription. + /// The id of the price on the plan to replace in the subscription. /// - public required string AdjustmentID + public required string ReplacesPriceID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment_id"); + return this._rawData.GetNotNullClass("replaces_price_id"); } - init { this._rawData.Set("adjustment_id", value); } - } - - /// - public override void Validate() - { - _ = this.AdjustmentID; - } - - public SubscriptionSchedulePlanChangeParamsRemoveAdjustment() { } - - public SubscriptionSchedulePlanChangeParamsRemoveAdjustment( - SubscriptionSchedulePlanChangeParamsRemoveAdjustment subscriptionSchedulePlanChangeParamsRemoveAdjustment - ) - : base(subscriptionSchedulePlanChangeParamsRemoveAdjustment) { } - - public SubscriptionSchedulePlanChangeParamsRemoveAdjustment( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsRemoveAdjustment( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); + init { this._rawData.Set("replaces_price_id", value); } } -#pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsRemoveAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + /// The definition of a new allocation price to create and add to the subscription. + /// + public NewAllocationPrice? AllocationPrice { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("allocation_price"); + } + init { this._rawData.Set("allocation_price", value); } } - [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsRemoveAdjustment(string adjustmentID) - : this() + /// + /// [DEPRECATED] Use add_adjustments instead. The subscription's discounts for + /// the replacement price. + /// + [System::Obsolete("deprecated")] + public IReadOnlyList? Discounts { - this.AdjustmentID = adjustmentID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("discounts"); + } + init + { + this._rawData.Set?>( + "discounts", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } } -} - -class SubscriptionSchedulePlanChangeParamsRemoveAdjustmentFromRaw - : IFromRawJson -{ - /// - public SubscriptionSchedulePlanChangeParamsRemoveAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsRemoveAdjustment.FromRawUnchecked(rawData); -} -[JsonConverter( - typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsRemovePrice, - SubscriptionSchedulePlanChangeParamsRemovePriceFromRaw - >) -)] -public sealed record class SubscriptionSchedulePlanChangeParamsRemovePrice : JsonModel -{ /// - /// The external price id of the price to remove on the subscription. + /// The external price id of the price to add to the subscription. /// public string? ExternalPriceID { @@ -10753,116 +10621,101 @@ public string? ExternalPriceID } /// - /// The id of the price to remove on the subscription. + /// The new quantity of the price, if the price is a fixed price. /// - public string? PriceID + public double? FixedPriceQuantity { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("price_id"); + return this._rawData.GetNullableStruct("fixed_price_quantity"); } - init { this._rawData.Set("price_id", value); } + init { this._rawData.Set("fixed_price_quantity", value); } } - /// - public override void Validate() + /// + /// [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount + /// for the replacement price. + /// + [System::Obsolete("deprecated")] + public string? MaximumAmount { - _ = this.ExternalPriceID; - _ = this.PriceID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("maximum_amount"); + } + init { this._rawData.Set("maximum_amount", value); } } - public SubscriptionSchedulePlanChangeParamsRemovePrice() { } - - public SubscriptionSchedulePlanChangeParamsRemovePrice( - SubscriptionSchedulePlanChangeParamsRemovePrice subscriptionSchedulePlanChangeParamsRemovePrice - ) - : base(subscriptionSchedulePlanChangeParamsRemovePrice) { } - - public SubscriptionSchedulePlanChangeParamsRemovePrice( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsRemovePrice(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static SubscriptionSchedulePlanChangeParamsRemovePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + /// [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount + /// for the replacement price. + /// + [System::Obsolete("deprecated")] + public string? MinimumAmount { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("minimum_amount"); + } + init { this._rawData.Set("minimum_amount", value); } } -} -class SubscriptionSchedulePlanChangeParamsRemovePriceFromRaw - : IFromRawJson -{ - /// - public SubscriptionSchedulePlanChangeParamsRemovePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsRemovePrice.FromRawUnchecked(rawData); -} - -[JsonConverter( - typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplaceAdjustment, - SubscriptionSchedulePlanChangeParamsReplaceAdjustmentFromRaw - >) -)] -public sealed record class SubscriptionSchedulePlanChangeParamsReplaceAdjustment : JsonModel -{ /// - /// The definition of a new adjustment to create and add to the subscription. + /// New subscription price request body params. /// - public required SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment Adjustment + public SubscriptionSchedulePlanChangeParamsReplacePricePrice? Price { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "adjustment" + return this._rawData.GetNullableClass( + "price" ); } - init { this._rawData.Set("adjustment", value); } + init { this._rawData.Set("price", value); } } /// - /// The id of the adjustment on the plan to replace in the subscription. + /// The id of the price to add to the subscription. /// - public required string ReplacesAdjustmentID + public string? PriceID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_adjustment_id"); + return this._rawData.GetNullableClass("price_id"); } - init { this._rawData.Set("replaces_adjustment_id", value); } + init { this._rawData.Set("price_id", value); } } /// public override void Validate() { - this.Adjustment.Validate(); - _ = this.ReplacesAdjustmentID; + _ = this.ReplacesPriceID; + this.AllocationPrice?.Validate(); + foreach (var item in this.Discounts ?? []) + { + item.Validate(); + } + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.MaximumAmount; + _ = this.MinimumAmount; + this.Price?.Validate(); + _ = this.PriceID; } - public SubscriptionSchedulePlanChangeParamsReplaceAdjustment() { } + public SubscriptionSchedulePlanChangeParamsReplacePrice() { } - public SubscriptionSchedulePlanChangeParamsReplaceAdjustment( - SubscriptionSchedulePlanChangeParamsReplaceAdjustment subscriptionSchedulePlanChangeParamsReplaceAdjustment + public SubscriptionSchedulePlanChangeParamsReplacePrice( + SubscriptionSchedulePlanChangeParamsReplacePrice subscriptionSchedulePlanChangeParamsReplacePrice ) - : base(subscriptionSchedulePlanChangeParamsReplaceAdjustment) { } + : base(subscriptionSchedulePlanChangeParamsReplacePrice) { } - public SubscriptionSchedulePlanChangeParamsReplaceAdjustment( + public SubscriptionSchedulePlanChangeParamsReplacePrice( IReadOnlyDictionary rawData ) { @@ -10871,37 +10724,42 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplaceAdjustment( - FrozenDictionary rawData - ) + SubscriptionSchedulePlanChangeParamsReplacePrice(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplaceAdjustment FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePrice FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } + + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePrice(string replacesPriceID) + : this() + { + this.ReplacesPriceID = replacesPriceID; + } } -class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePriceFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplaceAdjustment FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePrice FromRawUnchecked( IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsReplaceAdjustment.FromRawUnchecked(rawData); + ) => SubscriptionSchedulePlanChangeParamsReplacePrice.FromRawUnchecked(rawData); } /// -/// The definition of a new adjustment to create and add to the subscription. +/// New subscription price request body params. /// -[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentConverter))] -public record class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment : ModelBase +[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceConverter))] +public record class SubscriptionSchedulePlanChangeParamsReplacePricePrice : ModelBase { public object? Value { get; } = null; @@ -10918,4633 +10776,2809 @@ public JsonElement Json } } - public string? Currency + public string ItemID { get { - return Match( - newPercentageDiscount: (x) => x.Currency, - newUsageDiscount: (x) => x.Currency, - newAmountDiscount: (x) => x.Currency, - newMinimum: (x) => x.Currency, - newMaximum: (x) => x.Currency + return Match( + newSubscriptionUnit: (x) => x.ItemID, + newSubscriptionTiered: (x) => x.ItemID, + newSubscriptionBulk: (x) => x.ItemID, + bulkWithFilters: (x) => x.ItemID, + newSubscriptionPackage: (x) => x.ItemID, + newSubscriptionMatrix: (x) => x.ItemID, + newSubscriptionThresholdTotalAmount: (x) => x.ItemID, + newSubscriptionTieredPackage: (x) => x.ItemID, + newSubscriptionTieredWithMinimum: (x) => x.ItemID, + newSubscriptionGroupedTiered: (x) => x.ItemID, + newSubscriptionTieredPackageWithMinimum: (x) => x.ItemID, + newSubscriptionPackageWithAllocation: (x) => x.ItemID, + newSubscriptionUnitWithPercent: (x) => x.ItemID, + newSubscriptionMatrixWithAllocation: (x) => x.ItemID, + tieredWithProration: (x) => x.ItemID, + newSubscriptionUnitWithProration: (x) => x.ItemID, + newSubscriptionGroupedAllocation: (x) => x.ItemID, + newSubscriptionBulkWithProration: (x) => x.ItemID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.ItemID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.ItemID, + groupedWithMinMaxThresholds: (x) => x.ItemID, + newSubscriptionMatrixWithDisplayName: (x) => x.ItemID, + newSubscriptionGroupedTieredPackage: (x) => x.ItemID, + newSubscriptionMaxGroupTieredPackage: (x) => x.ItemID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ItemID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ItemID, + newSubscriptionCumulativeGroupedBulk: (x) => x.ItemID, + cumulativeGroupedAllocation: (x) => x.ItemID, + newSubscriptionMinimumComposite: (x) => x.ItemID, + percent: (x) => x.ItemID, + eventOutput: (x) => x.ItemID ); } } - public bool? IsInvoiceLevel + public string Name { get { - return Match( - newPercentageDiscount: (x) => x.IsInvoiceLevel, - newUsageDiscount: (x) => x.IsInvoiceLevel, - newAmountDiscount: (x) => x.IsInvoiceLevel, - newMinimum: (x) => x.IsInvoiceLevel, - newMaximum: (x) => x.IsInvoiceLevel + return Match( + newSubscriptionUnit: (x) => x.Name, + newSubscriptionTiered: (x) => x.Name, + newSubscriptionBulk: (x) => x.Name, + bulkWithFilters: (x) => x.Name, + newSubscriptionPackage: (x) => x.Name, + newSubscriptionMatrix: (x) => x.Name, + newSubscriptionThresholdTotalAmount: (x) => x.Name, + newSubscriptionTieredPackage: (x) => x.Name, + newSubscriptionTieredWithMinimum: (x) => x.Name, + newSubscriptionGroupedTiered: (x) => x.Name, + newSubscriptionTieredPackageWithMinimum: (x) => x.Name, + newSubscriptionPackageWithAllocation: (x) => x.Name, + newSubscriptionUnitWithPercent: (x) => x.Name, + newSubscriptionMatrixWithAllocation: (x) => x.Name, + tieredWithProration: (x) => x.Name, + newSubscriptionUnitWithProration: (x) => x.Name, + newSubscriptionGroupedAllocation: (x) => x.Name, + newSubscriptionBulkWithProration: (x) => x.Name, + newSubscriptionGroupedWithProratedMinimum: (x) => x.Name, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.Name, + groupedWithMinMaxThresholds: (x) => x.Name, + newSubscriptionMatrixWithDisplayName: (x) => x.Name, + newSubscriptionGroupedTieredPackage: (x) => x.Name, + newSubscriptionMaxGroupTieredPackage: (x) => x.Name, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.Name, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Name, + newSubscriptionCumulativeGroupedBulk: (x) => x.Name, + cumulativeGroupedAllocation: (x) => x.Name, + newSubscriptionMinimumComposite: (x) => x.Name, + percent: (x) => x.Name, + eventOutput: (x) => x.Name ); } } - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewPercentageDiscount value, - JsonElement? element = null - ) + public string? BillableMetricID { - this.Value = value; - this._element = element; + get + { + return Match( + newSubscriptionUnit: (x) => x.BillableMetricID, + newSubscriptionTiered: (x) => x.BillableMetricID, + newSubscriptionBulk: (x) => x.BillableMetricID, + bulkWithFilters: (x) => x.BillableMetricID, + newSubscriptionPackage: (x) => x.BillableMetricID, + newSubscriptionMatrix: (x) => x.BillableMetricID, + newSubscriptionThresholdTotalAmount: (x) => x.BillableMetricID, + newSubscriptionTieredPackage: (x) => x.BillableMetricID, + newSubscriptionTieredWithMinimum: (x) => x.BillableMetricID, + newSubscriptionGroupedTiered: (x) => x.BillableMetricID, + newSubscriptionTieredPackageWithMinimum: (x) => x.BillableMetricID, + newSubscriptionPackageWithAllocation: (x) => x.BillableMetricID, + newSubscriptionUnitWithPercent: (x) => x.BillableMetricID, + newSubscriptionMatrixWithAllocation: (x) => x.BillableMetricID, + tieredWithProration: (x) => x.BillableMetricID, + newSubscriptionUnitWithProration: (x) => x.BillableMetricID, + newSubscriptionGroupedAllocation: (x) => x.BillableMetricID, + newSubscriptionBulkWithProration: (x) => x.BillableMetricID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.BillableMetricID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.BillableMetricID, + groupedWithMinMaxThresholds: (x) => x.BillableMetricID, + newSubscriptionMatrixWithDisplayName: (x) => x.BillableMetricID, + newSubscriptionGroupedTieredPackage: (x) => x.BillableMetricID, + newSubscriptionMaxGroupTieredPackage: (x) => x.BillableMetricID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BillableMetricID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, + newSubscriptionCumulativeGroupedBulk: (x) => x.BillableMetricID, + cumulativeGroupedAllocation: (x) => x.BillableMetricID, + newSubscriptionMinimumComposite: (x) => x.BillableMetricID, + percent: (x) => x.BillableMetricID, + eventOutput: (x) => x.BillableMetricID + ); + } } - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewUsageDiscount value, - JsonElement? element = null - ) + public bool? BilledInAdvance { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewAmountDiscount value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; + get + { + return Match( + newSubscriptionUnit: (x) => x.BilledInAdvance, + newSubscriptionTiered: (x) => x.BilledInAdvance, + newSubscriptionBulk: (x) => x.BilledInAdvance, + bulkWithFilters: (x) => x.BilledInAdvance, + newSubscriptionPackage: (x) => x.BilledInAdvance, + newSubscriptionMatrix: (x) => x.BilledInAdvance, + newSubscriptionThresholdTotalAmount: (x) => x.BilledInAdvance, + newSubscriptionTieredPackage: (x) => x.BilledInAdvance, + newSubscriptionTieredWithMinimum: (x) => x.BilledInAdvance, + newSubscriptionGroupedTiered: (x) => x.BilledInAdvance, + newSubscriptionTieredPackageWithMinimum: (x) => x.BilledInAdvance, + newSubscriptionPackageWithAllocation: (x) => x.BilledInAdvance, + newSubscriptionUnitWithPercent: (x) => x.BilledInAdvance, + newSubscriptionMatrixWithAllocation: (x) => x.BilledInAdvance, + tieredWithProration: (x) => x.BilledInAdvance, + newSubscriptionUnitWithProration: (x) => x.BilledInAdvance, + newSubscriptionGroupedAllocation: (x) => x.BilledInAdvance, + newSubscriptionBulkWithProration: (x) => x.BilledInAdvance, + newSubscriptionGroupedWithProratedMinimum: (x) => x.BilledInAdvance, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.BilledInAdvance, + groupedWithMinMaxThresholds: (x) => x.BilledInAdvance, + newSubscriptionMatrixWithDisplayName: (x) => x.BilledInAdvance, + newSubscriptionGroupedTieredPackage: (x) => x.BilledInAdvance, + newSubscriptionMaxGroupTieredPackage: (x) => x.BilledInAdvance, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BilledInAdvance, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, + newSubscriptionCumulativeGroupedBulk: (x) => x.BilledInAdvance, + cumulativeGroupedAllocation: (x) => x.BilledInAdvance, + newSubscriptionMinimumComposite: (x) => x.BilledInAdvance, + percent: (x) => x.BilledInAdvance, + eventOutput: (x) => x.BilledInAdvance + ); + } } - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewMinimum value, - JsonElement? element = null - ) + public NewBillingCycleConfiguration? BillingCycleConfiguration { - this.Value = value; - this._element = element; + get + { + return Match( + newSubscriptionUnit: (x) => x.BillingCycleConfiguration, + newSubscriptionTiered: (x) => x.BillingCycleConfiguration, + newSubscriptionBulk: (x) => x.BillingCycleConfiguration, + bulkWithFilters: (x) => x.BillingCycleConfiguration, + newSubscriptionPackage: (x) => x.BillingCycleConfiguration, + newSubscriptionMatrix: (x) => x.BillingCycleConfiguration, + newSubscriptionThresholdTotalAmount: (x) => x.BillingCycleConfiguration, + newSubscriptionTieredPackage: (x) => x.BillingCycleConfiguration, + newSubscriptionTieredWithMinimum: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedTiered: (x) => x.BillingCycleConfiguration, + newSubscriptionTieredPackageWithMinimum: (x) => x.BillingCycleConfiguration, + newSubscriptionPackageWithAllocation: (x) => x.BillingCycleConfiguration, + newSubscriptionUnitWithPercent: (x) => x.BillingCycleConfiguration, + newSubscriptionMatrixWithAllocation: (x) => x.BillingCycleConfiguration, + tieredWithProration: (x) => x.BillingCycleConfiguration, + newSubscriptionUnitWithProration: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedAllocation: (x) => x.BillingCycleConfiguration, + newSubscriptionBulkWithProration: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedWithProratedMinimum: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.BillingCycleConfiguration, + groupedWithMinMaxThresholds: (x) => x.BillingCycleConfiguration, + newSubscriptionMatrixWithDisplayName: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedTieredPackage: (x) => x.BillingCycleConfiguration, + newSubscriptionMaxGroupTieredPackage: (x) => x.BillingCycleConfiguration, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BillingCycleConfiguration, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, + newSubscriptionCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, + cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, + newSubscriptionMinimumComposite: (x) => x.BillingCycleConfiguration, + percent: (x) => x.BillingCycleConfiguration, + eventOutput: (x) => x.BillingCycleConfiguration + ); + } } - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewMaximum value, - JsonElement? element = null - ) + public double? ConversionRate { - this.Value = value; - this._element = element; + get + { + return Match( + newSubscriptionUnit: (x) => x.ConversionRate, + newSubscriptionTiered: (x) => x.ConversionRate, + newSubscriptionBulk: (x) => x.ConversionRate, + bulkWithFilters: (x) => x.ConversionRate, + newSubscriptionPackage: (x) => x.ConversionRate, + newSubscriptionMatrix: (x) => x.ConversionRate, + newSubscriptionThresholdTotalAmount: (x) => x.ConversionRate, + newSubscriptionTieredPackage: (x) => x.ConversionRate, + newSubscriptionTieredWithMinimum: (x) => x.ConversionRate, + newSubscriptionGroupedTiered: (x) => x.ConversionRate, + newSubscriptionTieredPackageWithMinimum: (x) => x.ConversionRate, + newSubscriptionPackageWithAllocation: (x) => x.ConversionRate, + newSubscriptionUnitWithPercent: (x) => x.ConversionRate, + newSubscriptionMatrixWithAllocation: (x) => x.ConversionRate, + tieredWithProration: (x) => x.ConversionRate, + newSubscriptionUnitWithProration: (x) => x.ConversionRate, + newSubscriptionGroupedAllocation: (x) => x.ConversionRate, + newSubscriptionBulkWithProration: (x) => x.ConversionRate, + newSubscriptionGroupedWithProratedMinimum: (x) => x.ConversionRate, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.ConversionRate, + groupedWithMinMaxThresholds: (x) => x.ConversionRate, + newSubscriptionMatrixWithDisplayName: (x) => x.ConversionRate, + newSubscriptionGroupedTieredPackage: (x) => x.ConversionRate, + newSubscriptionMaxGroupTieredPackage: (x) => x.ConversionRate, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ConversionRate, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ConversionRate, + newSubscriptionCumulativeGroupedBulk: (x) => x.ConversionRate, + cumulativeGroupedAllocation: (x) => x.ConversionRate, + newSubscriptionMinimumComposite: (x) => x.ConversionRate, + percent: (x) => x.ConversionRate, + eventOutput: (x) => x.ConversionRate + ); + } } - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment(JsonElement element) + public string? Currency { - this._element = element; + get + { + return Match( + newSubscriptionUnit: (x) => x.Currency, + newSubscriptionTiered: (x) => x.Currency, + newSubscriptionBulk: (x) => x.Currency, + bulkWithFilters: (x) => x.Currency, + newSubscriptionPackage: (x) => x.Currency, + newSubscriptionMatrix: (x) => x.Currency, + newSubscriptionThresholdTotalAmount: (x) => x.Currency, + newSubscriptionTieredPackage: (x) => x.Currency, + newSubscriptionTieredWithMinimum: (x) => x.Currency, + newSubscriptionGroupedTiered: (x) => x.Currency, + newSubscriptionTieredPackageWithMinimum: (x) => x.Currency, + newSubscriptionPackageWithAllocation: (x) => x.Currency, + newSubscriptionUnitWithPercent: (x) => x.Currency, + newSubscriptionMatrixWithAllocation: (x) => x.Currency, + tieredWithProration: (x) => x.Currency, + newSubscriptionUnitWithProration: (x) => x.Currency, + newSubscriptionGroupedAllocation: (x) => x.Currency, + newSubscriptionBulkWithProration: (x) => x.Currency, + newSubscriptionGroupedWithProratedMinimum: (x) => x.Currency, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.Currency, + groupedWithMinMaxThresholds: (x) => x.Currency, + newSubscriptionMatrixWithDisplayName: (x) => x.Currency, + newSubscriptionGroupedTieredPackage: (x) => x.Currency, + newSubscriptionMaxGroupTieredPackage: (x) => x.Currency, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.Currency, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Currency, + newSubscriptionCumulativeGroupedBulk: (x) => x.Currency, + cumulativeGroupedAllocation: (x) => x.Currency, + newSubscriptionMinimumComposite: (x) => x.Currency, + percent: (x) => x.Currency, + eventOutput: (x) => x.Currency + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPercentageDiscount(out var value)) { - /// // `value` is of type `NewPercentageDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { - value = this.Value as NewPercentageDiscount; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.DimensionalPriceConfiguration, + newSubscriptionTiered: (x) => x.DimensionalPriceConfiguration, + newSubscriptionBulk: (x) => x.DimensionalPriceConfiguration, + bulkWithFilters: (x) => x.DimensionalPriceConfiguration, + newSubscriptionPackage: (x) => x.DimensionalPriceConfiguration, + newSubscriptionMatrix: (x) => x.DimensionalPriceConfiguration, + newSubscriptionThresholdTotalAmount: (x) => x.DimensionalPriceConfiguration, + newSubscriptionTieredPackage: (x) => x.DimensionalPriceConfiguration, + newSubscriptionTieredWithMinimum: (x) => x.DimensionalPriceConfiguration, + newSubscriptionGroupedTiered: (x) => x.DimensionalPriceConfiguration, + newSubscriptionTieredPackageWithMinimum: (x) => x.DimensionalPriceConfiguration, + newSubscriptionPackageWithAllocation: (x) => x.DimensionalPriceConfiguration, + newSubscriptionUnitWithPercent: (x) => x.DimensionalPriceConfiguration, + newSubscriptionMatrixWithAllocation: (x) => x.DimensionalPriceConfiguration, + tieredWithProration: (x) => x.DimensionalPriceConfiguration, + newSubscriptionUnitWithProration: (x) => x.DimensionalPriceConfiguration, + newSubscriptionGroupedAllocation: (x) => x.DimensionalPriceConfiguration, + newSubscriptionBulkWithProration: (x) => x.DimensionalPriceConfiguration, + newSubscriptionGroupedWithProratedMinimum: (x) => x.DimensionalPriceConfiguration, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.DimensionalPriceConfiguration, + groupedWithMinMaxThresholds: (x) => x.DimensionalPriceConfiguration, + newSubscriptionMatrixWithDisplayName: (x) => x.DimensionalPriceConfiguration, + newSubscriptionGroupedTieredPackage: (x) => x.DimensionalPriceConfiguration, + newSubscriptionMaxGroupTieredPackage: (x) => x.DimensionalPriceConfiguration, + newSubscriptionScalableMatrixWithUnitPricing: (x) => + x.DimensionalPriceConfiguration, + newSubscriptionScalableMatrixWithTieredPricing: (x) => + x.DimensionalPriceConfiguration, + newSubscriptionCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, + cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, + newSubscriptionMinimumComposite: (x) => x.DimensionalPriceConfiguration, + percent: (x) => x.DimensionalPriceConfiguration, + eventOutput: (x) => x.DimensionalPriceConfiguration + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewUsageDiscount(out var value)) { - /// // `value` is of type `NewUsageDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) + public string? ExternalPriceID { - value = this.Value as NewUsageDiscount; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewAmountDiscount(out var value)) { - /// // `value` is of type `NewAmountDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) - { - value = this.Value as NewAmountDiscount; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.ExternalPriceID, + newSubscriptionTiered: (x) => x.ExternalPriceID, + newSubscriptionBulk: (x) => x.ExternalPriceID, + bulkWithFilters: (x) => x.ExternalPriceID, + newSubscriptionPackage: (x) => x.ExternalPriceID, + newSubscriptionMatrix: (x) => x.ExternalPriceID, + newSubscriptionThresholdTotalAmount: (x) => x.ExternalPriceID, + newSubscriptionTieredPackage: (x) => x.ExternalPriceID, + newSubscriptionTieredWithMinimum: (x) => x.ExternalPriceID, + newSubscriptionGroupedTiered: (x) => x.ExternalPriceID, + newSubscriptionTieredPackageWithMinimum: (x) => x.ExternalPriceID, + newSubscriptionPackageWithAllocation: (x) => x.ExternalPriceID, + newSubscriptionUnitWithPercent: (x) => x.ExternalPriceID, + newSubscriptionMatrixWithAllocation: (x) => x.ExternalPriceID, + tieredWithProration: (x) => x.ExternalPriceID, + newSubscriptionUnitWithProration: (x) => x.ExternalPriceID, + newSubscriptionGroupedAllocation: (x) => x.ExternalPriceID, + newSubscriptionBulkWithProration: (x) => x.ExternalPriceID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.ExternalPriceID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.ExternalPriceID, + groupedWithMinMaxThresholds: (x) => x.ExternalPriceID, + newSubscriptionMatrixWithDisplayName: (x) => x.ExternalPriceID, + newSubscriptionGroupedTieredPackage: (x) => x.ExternalPriceID, + newSubscriptionMaxGroupTieredPackage: (x) => x.ExternalPriceID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ExternalPriceID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, + newSubscriptionCumulativeGroupedBulk: (x) => x.ExternalPriceID, + cumulativeGroupedAllocation: (x) => x.ExternalPriceID, + newSubscriptionMinimumComposite: (x) => x.ExternalPriceID, + percent: (x) => x.ExternalPriceID, + eventOutput: (x) => x.ExternalPriceID + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewMinimum(out var value)) { - /// // `value` is of type `NewMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? value) + public double? FixedPriceQuantity { - value = this.Value as NewMinimum; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.FixedPriceQuantity, + newSubscriptionTiered: (x) => x.FixedPriceQuantity, + newSubscriptionBulk: (x) => x.FixedPriceQuantity, + bulkWithFilters: (x) => x.FixedPriceQuantity, + newSubscriptionPackage: (x) => x.FixedPriceQuantity, + newSubscriptionMatrix: (x) => x.FixedPriceQuantity, + newSubscriptionThresholdTotalAmount: (x) => x.FixedPriceQuantity, + newSubscriptionTieredPackage: (x) => x.FixedPriceQuantity, + newSubscriptionTieredWithMinimum: (x) => x.FixedPriceQuantity, + newSubscriptionGroupedTiered: (x) => x.FixedPriceQuantity, + newSubscriptionTieredPackageWithMinimum: (x) => x.FixedPriceQuantity, + newSubscriptionPackageWithAllocation: (x) => x.FixedPriceQuantity, + newSubscriptionUnitWithPercent: (x) => x.FixedPriceQuantity, + newSubscriptionMatrixWithAllocation: (x) => x.FixedPriceQuantity, + tieredWithProration: (x) => x.FixedPriceQuantity, + newSubscriptionUnitWithProration: (x) => x.FixedPriceQuantity, + newSubscriptionGroupedAllocation: (x) => x.FixedPriceQuantity, + newSubscriptionBulkWithProration: (x) => x.FixedPriceQuantity, + newSubscriptionGroupedWithProratedMinimum: (x) => x.FixedPriceQuantity, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.FixedPriceQuantity, + groupedWithMinMaxThresholds: (x) => x.FixedPriceQuantity, + newSubscriptionMatrixWithDisplayName: (x) => x.FixedPriceQuantity, + newSubscriptionGroupedTieredPackage: (x) => x.FixedPriceQuantity, + newSubscriptionMaxGroupTieredPackage: (x) => x.FixedPriceQuantity, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.FixedPriceQuantity, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, + newSubscriptionCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, + cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, + newSubscriptionMinimumComposite: (x) => x.FixedPriceQuantity, + percent: (x) => x.FixedPriceQuantity, + eventOutput: (x) => x.FixedPriceQuantity + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewMaximum(out var value)) { - /// // `value` is of type `NewMaximum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) + public string? InvoiceGroupingKey { - value = this.Value as NewMaximum; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.InvoiceGroupingKey, + newSubscriptionTiered: (x) => x.InvoiceGroupingKey, + newSubscriptionBulk: (x) => x.InvoiceGroupingKey, + bulkWithFilters: (x) => x.InvoiceGroupingKey, + newSubscriptionPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionMatrix: (x) => x.InvoiceGroupingKey, + newSubscriptionThresholdTotalAmount: (x) => x.InvoiceGroupingKey, + newSubscriptionTieredPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionTieredWithMinimum: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedTiered: (x) => x.InvoiceGroupingKey, + newSubscriptionTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, + newSubscriptionPackageWithAllocation: (x) => x.InvoiceGroupingKey, + newSubscriptionUnitWithPercent: (x) => x.InvoiceGroupingKey, + newSubscriptionMatrixWithAllocation: (x) => x.InvoiceGroupingKey, + tieredWithProration: (x) => x.InvoiceGroupingKey, + newSubscriptionUnitWithProration: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedAllocation: (x) => x.InvoiceGroupingKey, + newSubscriptionBulkWithProration: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.InvoiceGroupingKey, + groupedWithMinMaxThresholds: (x) => x.InvoiceGroupingKey, + newSubscriptionMatrixWithDisplayName: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedTieredPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionMaxGroupTieredPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, + newSubscriptionCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, + cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, + newSubscriptionMinimumComposite: (x) => x.InvoiceGroupingKey, + percent: (x) => x.InvoiceGroupingKey, + eventOutput: (x) => x.InvoiceGroupingKey + ); + } } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action newPercentageDiscount, - System::Action newUsageDiscount, - System::Action newAmountDiscount, - System::Action newMinimum, - System::Action newMaximum - ) + public NewBillingCycleConfiguration? InvoicingCycleConfiguration { - switch (this.Value) + get { - case NewPercentageDiscount value: - newPercentageDiscount(value); - break; - case NewUsageDiscount value: - newUsageDiscount(value); - break; - case NewAmountDiscount value: - newAmountDiscount(value); - break; - case NewMinimum value: - newMinimum(value); - break; - case NewMaximum value: - newMaximum(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment" - ); + return Match( + newSubscriptionUnit: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTiered: (x) => x.InvoicingCycleConfiguration, + newSubscriptionBulk: (x) => x.InvoicingCycleConfiguration, + bulkWithFilters: (x) => x.InvoicingCycleConfiguration, + newSubscriptionPackage: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMatrix: (x) => x.InvoicingCycleConfiguration, + newSubscriptionThresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTieredPackage: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTieredWithMinimum: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedTiered: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, + newSubscriptionPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, + newSubscriptionUnitWithPercent: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, + tieredWithProration: (x) => x.InvoicingCycleConfiguration, + newSubscriptionUnitWithProration: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedAllocation: (x) => x.InvoicingCycleConfiguration, + newSubscriptionBulkWithProration: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedWithProratedMinimum: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.InvoicingCycleConfiguration, + groupedWithMinMaxThresholds: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMatrixWithDisplayName: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedTieredPackage: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMaxGroupTieredPackage: (x) => x.InvoicingCycleConfiguration, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.InvoicingCycleConfiguration, + newSubscriptionScalableMatrixWithTieredPricing: (x) => + x.InvoicingCycleConfiguration, + newSubscriptionCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, + cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMinimumComposite: (x) => x.InvoicingCycleConfiguration, + percent: (x) => x.InvoicingCycleConfiguration, + eventOutput: (x) => x.InvoicingCycleConfiguration + ); } } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func newPercentageDiscount, - System::Func newUsageDiscount, - System::Func newAmountDiscount, - System::Func newMinimum, - System::Func newMaximum - ) + public string? ReferenceID { - return this.Value switch + get { - NewPercentageDiscount value => newPercentageDiscount(value), - NewUsageDiscount value => newUsageDiscount(value), - NewAmountDiscount value => newAmountDiscount(value), - NewMinimum value => newMinimum(value), - NewMaximum value => newMaximum(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment" - ), - }; + return Match( + newSubscriptionUnit: (x) => x.ReferenceID, + newSubscriptionTiered: (x) => x.ReferenceID, + newSubscriptionBulk: (x) => x.ReferenceID, + bulkWithFilters: (x) => x.ReferenceID, + newSubscriptionPackage: (x) => x.ReferenceID, + newSubscriptionMatrix: (x) => x.ReferenceID, + newSubscriptionThresholdTotalAmount: (x) => x.ReferenceID, + newSubscriptionTieredPackage: (x) => x.ReferenceID, + newSubscriptionTieredWithMinimum: (x) => x.ReferenceID, + newSubscriptionGroupedTiered: (x) => x.ReferenceID, + newSubscriptionTieredPackageWithMinimum: (x) => x.ReferenceID, + newSubscriptionPackageWithAllocation: (x) => x.ReferenceID, + newSubscriptionUnitWithPercent: (x) => x.ReferenceID, + newSubscriptionMatrixWithAllocation: (x) => x.ReferenceID, + tieredWithProration: (x) => x.ReferenceID, + newSubscriptionUnitWithProration: (x) => x.ReferenceID, + newSubscriptionGroupedAllocation: (x) => x.ReferenceID, + newSubscriptionBulkWithProration: (x) => x.ReferenceID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.ReferenceID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.ReferenceID, + groupedWithMinMaxThresholds: (x) => x.ReferenceID, + newSubscriptionMatrixWithDisplayName: (x) => x.ReferenceID, + newSubscriptionGroupedTieredPackage: (x) => x.ReferenceID, + newSubscriptionMaxGroupTieredPackage: (x) => x.ReferenceID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ReferenceID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ReferenceID, + newSubscriptionCumulativeGroupedBulk: (x) => x.ReferenceID, + cumulativeGroupedAllocation: (x) => x.ReferenceID, + newSubscriptionMinimumComposite: (x) => x.ReferenceID, + percent: (x) => x.ReferenceID, + eventOutput: (x) => x.ReferenceID + ); + } } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewPercentageDiscount value - ) => new(value); + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionUnitPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewUsageDiscount value - ) => new(value); + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewAmountDiscount value - ) => new(value); + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionBulkPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewMinimum value - ) => new(value); + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewMaximum value - ) => new(value); + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionPackagePrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMatrixPrice value, + JsonElement? element = null + ) { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment" - ); - } - this.Switch( - (newPercentageDiscount) => newPercentageDiscount.Validate(), - (newUsageDiscount) => newUsageDiscount.Validate(), - (newAmountDiscount) => newAmountDiscount.Validate(), - (newMinimum) => newMinimum.Validate(), - (newMaximum) => newMaximum.Validate() - ); + this.Value = value; + this._element = element; } - public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment? other + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionThresholdTotalAmountPrice value, + JsonElement? element = null ) { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); + this.Value = value; + this._element = element; } - public override int GetHashCode() + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredPackagePrice value, + JsonElement? element = null + ) { - return 0; + this.Value = value; + this._element = element; } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredWithMinimumPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } -sealed class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentConverter - : JsonConverter -{ - public override SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedTieredPrice value, + JsonElement? element = null ) { - var element = JsonSerializer.Deserialize(ref reader, options); - string? adjustmentType; - try - { - adjustmentType = element.GetProperty("adjustment_type").GetString(); - } - catch - { - adjustmentType = null; - } + this.Value = value; + this._element = element; + } - switch (adjustmentType) - { - case "percentage_discount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredPackageWithMinimumPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "usage_discount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionPackageWithAllocationPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "amount_discount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = JsonSerializer.Deserialize(element, options); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "maximum": - { - try - { - var deserialized = JsonSerializer.Deserialize(element, options); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment(element); - } - } + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionUnitWithPercentPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; } - public override void Write( - Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value, - JsonSerializerOptions options + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMatrixWithAllocationPrice value, + JsonElement? element = null ) { - JsonSerializer.Serialize(writer, value.Json, options); + this.Value = value; + this._element = element; } -} -[JsonConverter( - typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePrice, - SubscriptionSchedulePlanChangeParamsReplacePriceFromRaw - >) -)] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePrice : JsonModel -{ - /// - /// The id of the price on the plan to replace in the subscription. - /// - public required string ReplacesPriceID + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_price_id"); - } - init { this._rawData.Set("replaces_price_id", value); } + this.Value = value; + this._element = element; } - /// - /// The definition of a new allocation price to create and add to the subscription. - /// - public NewAllocationPrice? AllocationPrice + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionUnitWithProrationPrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("allocation_price"); - } - init { this._rawData.Set("allocation_price", value); } + this.Value = value; + this._element = element; } - /// - /// [DEPRECATED] Use add_adjustments instead. The subscription's discounts for - /// the replacement price. - /// - [System::Obsolete("deprecated")] - public IReadOnlyList? Discounts + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedAllocationPrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct>("discounts"); - } - init - { - this._rawData.Set?>( - "discounts", - value == null ? null : ImmutableArray.ToImmutableArray(value) - ); - } + this.Value = value; + this._element = element; } - /// - /// The external price id of the price to add to the subscription. - /// - public string? ExternalPriceID + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionBulkWithProrationPrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } + this.Value = value; + this._element = element; } - /// - /// The new quantity of the price, if the price is a fixed price. - /// - public double? FixedPriceQuantity + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedWithProratedMinimumPrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } + this.Value = value; + this._element = element; } - /// - /// [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount - /// for the replacement price. - /// - [System::Obsolete("deprecated")] - public string? MaximumAmount + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedWithMeteredMinimumPrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("maximum_amount"); - } - init { this._rawData.Set("maximum_amount", value); } + this.Value = value; + this._element = element; } - /// - /// [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount - /// for the replacement price. - /// - [System::Obsolete("deprecated")] - public string? MinimumAmount + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("minimum_amount"); - } - init { this._rawData.Set("minimum_amount", value); } + this.Value = value; + this._element = element; } - /// - /// New subscription price request body params. - /// - public SubscriptionSchedulePlanChangeParamsReplacePricePrice? Price + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMatrixWithDisplayNamePrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "price" - ); - } - init { this._rawData.Set("price", value); } + this.Value = value; + this._element = element; } - /// - /// The id of the price to add to the subscription. - /// - public string? PriceID + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedTieredPackagePrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("price_id"); - } - init { this._rawData.Set("price_id", value); } + this.Value = value; + this._element = element; } - /// - public override void Validate() + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMaxGroupTieredPackagePrice value, + JsonElement? element = null + ) { - _ = this.ReplacesPriceID; - this.AllocationPrice?.Validate(); - foreach (var item in this.Discounts ?? []) - { - item.Validate(); - } - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.MaximumAmount; - _ = this.MinimumAmount; - this.Price?.Validate(); - _ = this.PriceID; + this.Value = value; + this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePrice() { } - - public SubscriptionSchedulePlanChangeParamsReplacePrice( - SubscriptionSchedulePlanChangeParamsReplacePrice subscriptionSchedulePlanChangeParamsReplacePrice + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionScalableMatrixWithUnitPricingPrice value, + JsonElement? element = null ) - : base(subscriptionSchedulePlanChangeParamsReplacePrice) { } + { + this.Value = value; + this._element = element; + } - public SubscriptionSchedulePlanChangeParamsReplacePrice( - IReadOnlyDictionary rawData + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionScalableMatrixWithTieredPricingPrice value, + JsonElement? element = null ) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePrice(FrozenDictionary rawData) + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionCumulativeGroupedBulkPrice value, + JsonElement? element = null + ) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePrice FromRawUnchecked( - IReadOnlyDictionary rawData + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value, + JsonElement? element = null ) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this.Value = value; + this._element = element; } - [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsReplacePrice(string replacesPriceID) - : this() + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMinimumCompositePrice value, + JsonElement? element = null + ) { - this.ReplacesPriceID = replacesPriceID; + this.Value = value; + this._element = element; } -} - -class SubscriptionSchedulePlanChangeParamsReplacePriceFromRaw - : IFromRawJson -{ - /// - public SubscriptionSchedulePlanChangeParamsReplacePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsReplacePrice.FromRawUnchecked(rawData); -} - -/// -/// New subscription price request body params. -/// -[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceConverter))] -public record class SubscriptionSchedulePlanChangeParamsReplacePricePrice : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - public JsonElement Json + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value, + JsonElement? element = null + ) { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } + this.Value = value; + this._element = element; } - public string ItemID + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value, + JsonElement? element = null + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.ItemID, - newSubscriptionTiered: (x) => x.ItemID, - newSubscriptionBulk: (x) => x.ItemID, - bulkWithFilters: (x) => x.ItemID, - newSubscriptionPackage: (x) => x.ItemID, - newSubscriptionMatrix: (x) => x.ItemID, - newSubscriptionThresholdTotalAmount: (x) => x.ItemID, - newSubscriptionTieredPackage: (x) => x.ItemID, - newSubscriptionTieredWithMinimum: (x) => x.ItemID, - newSubscriptionGroupedTiered: (x) => x.ItemID, - newSubscriptionTieredPackageWithMinimum: (x) => x.ItemID, - newSubscriptionPackageWithAllocation: (x) => x.ItemID, - newSubscriptionUnitWithPercent: (x) => x.ItemID, - newSubscriptionMatrixWithAllocation: (x) => x.ItemID, - tieredWithProration: (x) => x.ItemID, - newSubscriptionUnitWithProration: (x) => x.ItemID, - newSubscriptionGroupedAllocation: (x) => x.ItemID, - newSubscriptionBulkWithProration: (x) => x.ItemID, - newSubscriptionGroupedWithProratedMinimum: (x) => x.ItemID, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.ItemID, - groupedWithMinMaxThresholds: (x) => x.ItemID, - newSubscriptionMatrixWithDisplayName: (x) => x.ItemID, - newSubscriptionGroupedTieredPackage: (x) => x.ItemID, - newSubscriptionMaxGroupTieredPackage: (x) => x.ItemID, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ItemID, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ItemID, - newSubscriptionCumulativeGroupedBulk: (x) => x.ItemID, - cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, - newSubscriptionMinimumComposite: (x) => x.ItemID, - percent: (x) => x.ItemID, - eventOutput: (x) => x.ItemID - ); - } + this.Value = value; + this._element = element; } - public string Name + public SubscriptionSchedulePlanChangeParamsReplacePricePrice(JsonElement element) { - get - { - return Match( - newSubscriptionUnit: (x) => x.Name, - newSubscriptionTiered: (x) => x.Name, - newSubscriptionBulk: (x) => x.Name, - bulkWithFilters: (x) => x.Name, - newSubscriptionPackage: (x) => x.Name, - newSubscriptionMatrix: (x) => x.Name, - newSubscriptionThresholdTotalAmount: (x) => x.Name, - newSubscriptionTieredPackage: (x) => x.Name, - newSubscriptionTieredWithMinimum: (x) => x.Name, - newSubscriptionGroupedTiered: (x) => x.Name, - newSubscriptionTieredPackageWithMinimum: (x) => x.Name, - newSubscriptionPackageWithAllocation: (x) => x.Name, - newSubscriptionUnitWithPercent: (x) => x.Name, - newSubscriptionMatrixWithAllocation: (x) => x.Name, - tieredWithProration: (x) => x.Name, - newSubscriptionUnitWithProration: (x) => x.Name, - newSubscriptionGroupedAllocation: (x) => x.Name, - newSubscriptionBulkWithProration: (x) => x.Name, - newSubscriptionGroupedWithProratedMinimum: (x) => x.Name, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.Name, - groupedWithMinMaxThresholds: (x) => x.Name, - newSubscriptionMatrixWithDisplayName: (x) => x.Name, - newSubscriptionGroupedTieredPackage: (x) => x.Name, - newSubscriptionMaxGroupTieredPackage: (x) => x.Name, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.Name, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Name, - newSubscriptionCumulativeGroupedBulk: (x) => x.Name, - cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, - newSubscriptionMinimumComposite: (x) => x.Name, - percent: (x) => x.Name, - eventOutput: (x) => x.Name - ); - } + this._element = element; } - public string? BillableMetricID + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionUnit(out var value)) { + /// // `value` is of type `NewSubscriptionUnitPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionUnit([NotNullWhen(true)] out NewSubscriptionUnitPrice? value) { - get - { - return Match( - newSubscriptionUnit: (x) => x.BillableMetricID, - newSubscriptionTiered: (x) => x.BillableMetricID, - newSubscriptionBulk: (x) => x.BillableMetricID, - bulkWithFilters: (x) => x.BillableMetricID, - newSubscriptionPackage: (x) => x.BillableMetricID, - newSubscriptionMatrix: (x) => x.BillableMetricID, - newSubscriptionThresholdTotalAmount: (x) => x.BillableMetricID, - newSubscriptionTieredPackage: (x) => x.BillableMetricID, - newSubscriptionTieredWithMinimum: (x) => x.BillableMetricID, - newSubscriptionGroupedTiered: (x) => x.BillableMetricID, - newSubscriptionTieredPackageWithMinimum: (x) => x.BillableMetricID, - newSubscriptionPackageWithAllocation: (x) => x.BillableMetricID, - newSubscriptionUnitWithPercent: (x) => x.BillableMetricID, - newSubscriptionMatrixWithAllocation: (x) => x.BillableMetricID, - tieredWithProration: (x) => x.BillableMetricID, - newSubscriptionUnitWithProration: (x) => x.BillableMetricID, - newSubscriptionGroupedAllocation: (x) => x.BillableMetricID, - newSubscriptionBulkWithProration: (x) => x.BillableMetricID, - newSubscriptionGroupedWithProratedMinimum: (x) => x.BillableMetricID, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.BillableMetricID, - groupedWithMinMaxThresholds: (x) => x.BillableMetricID, - newSubscriptionMatrixWithDisplayName: (x) => x.BillableMetricID, - newSubscriptionGroupedTieredPackage: (x) => x.BillableMetricID, - newSubscriptionMaxGroupTieredPackage: (x) => x.BillableMetricID, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BillableMetricID, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, - newSubscriptionCumulativeGroupedBulk: (x) => x.BillableMetricID, - cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, - newSubscriptionMinimumComposite: (x) => x.BillableMetricID, - percent: (x) => x.BillableMetricID, - eventOutput: (x) => x.BillableMetricID - ); - } + value = this.Value as NewSubscriptionUnitPrice; + return value != null; } - public bool? BilledInAdvance + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionTiered(out var value)) { + /// // `value` is of type `NewSubscriptionTieredPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionTiered( + [NotNullWhen(true)] out NewSubscriptionTieredPrice? value + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.BilledInAdvance, - newSubscriptionTiered: (x) => x.BilledInAdvance, - newSubscriptionBulk: (x) => x.BilledInAdvance, - bulkWithFilters: (x) => x.BilledInAdvance, - newSubscriptionPackage: (x) => x.BilledInAdvance, - newSubscriptionMatrix: (x) => x.BilledInAdvance, - newSubscriptionThresholdTotalAmount: (x) => x.BilledInAdvance, - newSubscriptionTieredPackage: (x) => x.BilledInAdvance, - newSubscriptionTieredWithMinimum: (x) => x.BilledInAdvance, - newSubscriptionGroupedTiered: (x) => x.BilledInAdvance, - newSubscriptionTieredPackageWithMinimum: (x) => x.BilledInAdvance, - newSubscriptionPackageWithAllocation: (x) => x.BilledInAdvance, - newSubscriptionUnitWithPercent: (x) => x.BilledInAdvance, - newSubscriptionMatrixWithAllocation: (x) => x.BilledInAdvance, - tieredWithProration: (x) => x.BilledInAdvance, - newSubscriptionUnitWithProration: (x) => x.BilledInAdvance, - newSubscriptionGroupedAllocation: (x) => x.BilledInAdvance, - newSubscriptionBulkWithProration: (x) => x.BilledInAdvance, - newSubscriptionGroupedWithProratedMinimum: (x) => x.BilledInAdvance, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.BilledInAdvance, - groupedWithMinMaxThresholds: (x) => x.BilledInAdvance, - newSubscriptionMatrixWithDisplayName: (x) => x.BilledInAdvance, - newSubscriptionGroupedTieredPackage: (x) => x.BilledInAdvance, - newSubscriptionMaxGroupTieredPackage: (x) => x.BilledInAdvance, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BilledInAdvance, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, - newSubscriptionCumulativeGroupedBulk: (x) => x.BilledInAdvance, - cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, - newSubscriptionMinimumComposite: (x) => x.BilledInAdvance, - percent: (x) => x.BilledInAdvance, - eventOutput: (x) => x.BilledInAdvance - ); - } + value = this.Value as NewSubscriptionTieredPrice; + return value != null; } - public NewBillingCycleConfiguration? BillingCycleConfiguration + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionBulk(out var value)) { + /// // `value` is of type `NewSubscriptionBulkPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionBulk([NotNullWhen(true)] out NewSubscriptionBulkPrice? value) { - get - { - return Match( - newSubscriptionUnit: (x) => x.BillingCycleConfiguration, - newSubscriptionTiered: (x) => x.BillingCycleConfiguration, - newSubscriptionBulk: (x) => x.BillingCycleConfiguration, - bulkWithFilters: (x) => x.BillingCycleConfiguration, - newSubscriptionPackage: (x) => x.BillingCycleConfiguration, - newSubscriptionMatrix: (x) => x.BillingCycleConfiguration, - newSubscriptionThresholdTotalAmount: (x) => x.BillingCycleConfiguration, - newSubscriptionTieredPackage: (x) => x.BillingCycleConfiguration, - newSubscriptionTieredWithMinimum: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedTiered: (x) => x.BillingCycleConfiguration, - newSubscriptionTieredPackageWithMinimum: (x) => x.BillingCycleConfiguration, - newSubscriptionPackageWithAllocation: (x) => x.BillingCycleConfiguration, - newSubscriptionUnitWithPercent: (x) => x.BillingCycleConfiguration, - newSubscriptionMatrixWithAllocation: (x) => x.BillingCycleConfiguration, - tieredWithProration: (x) => x.BillingCycleConfiguration, - newSubscriptionUnitWithProration: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedAllocation: (x) => x.BillingCycleConfiguration, - newSubscriptionBulkWithProration: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedWithProratedMinimum: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.BillingCycleConfiguration, - groupedWithMinMaxThresholds: (x) => x.BillingCycleConfiguration, - newSubscriptionMatrixWithDisplayName: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedTieredPackage: (x) => x.BillingCycleConfiguration, - newSubscriptionMaxGroupTieredPackage: (x) => x.BillingCycleConfiguration, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BillingCycleConfiguration, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, - newSubscriptionCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, - cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, - newSubscriptionMinimumComposite: (x) => x.BillingCycleConfiguration, - percent: (x) => x.BillingCycleConfiguration, - eventOutput: (x) => x.BillingCycleConfiguration - ); - } + value = this.Value as NewSubscriptionBulkPrice; + return value != null; } - public double? ConversionRate + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBulkWithFilters(out var value)) { + /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulkWithFilters( + [NotNullWhen(true)] + out SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters? value + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.ConversionRate, - newSubscriptionTiered: (x) => x.ConversionRate, - newSubscriptionBulk: (x) => x.ConversionRate, - bulkWithFilters: (x) => x.ConversionRate, - newSubscriptionPackage: (x) => x.ConversionRate, - newSubscriptionMatrix: (x) => x.ConversionRate, - newSubscriptionThresholdTotalAmount: (x) => x.ConversionRate, - newSubscriptionTieredPackage: (x) => x.ConversionRate, - newSubscriptionTieredWithMinimum: (x) => x.ConversionRate, - newSubscriptionGroupedTiered: (x) => x.ConversionRate, - newSubscriptionTieredPackageWithMinimum: (x) => x.ConversionRate, - newSubscriptionPackageWithAllocation: (x) => x.ConversionRate, - newSubscriptionUnitWithPercent: (x) => x.ConversionRate, - newSubscriptionMatrixWithAllocation: (x) => x.ConversionRate, - tieredWithProration: (x) => x.ConversionRate, - newSubscriptionUnitWithProration: (x) => x.ConversionRate, - newSubscriptionGroupedAllocation: (x) => x.ConversionRate, - newSubscriptionBulkWithProration: (x) => x.ConversionRate, - newSubscriptionGroupedWithProratedMinimum: (x) => x.ConversionRate, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.ConversionRate, - groupedWithMinMaxThresholds: (x) => x.ConversionRate, - newSubscriptionMatrixWithDisplayName: (x) => x.ConversionRate, - newSubscriptionGroupedTieredPackage: (x) => x.ConversionRate, - newSubscriptionMaxGroupTieredPackage: (x) => x.ConversionRate, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ConversionRate, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ConversionRate, - newSubscriptionCumulativeGroupedBulk: (x) => x.ConversionRate, - cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, - newSubscriptionMinimumComposite: (x) => x.ConversionRate, - percent: (x) => x.ConversionRate, - eventOutput: (x) => x.ConversionRate - ); - } + value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters; + return value != null; } - public string? Currency + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionPackage(out var value)) { + /// // `value` is of type `NewSubscriptionPackagePrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionPackage( + [NotNullWhen(true)] out NewSubscriptionPackagePrice? value + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.Currency, - newSubscriptionTiered: (x) => x.Currency, - newSubscriptionBulk: (x) => x.Currency, - bulkWithFilters: (x) => x.Currency, - newSubscriptionPackage: (x) => x.Currency, - newSubscriptionMatrix: (x) => x.Currency, - newSubscriptionThresholdTotalAmount: (x) => x.Currency, - newSubscriptionTieredPackage: (x) => x.Currency, - newSubscriptionTieredWithMinimum: (x) => x.Currency, - newSubscriptionGroupedTiered: (x) => x.Currency, - newSubscriptionTieredPackageWithMinimum: (x) => x.Currency, - newSubscriptionPackageWithAllocation: (x) => x.Currency, - newSubscriptionUnitWithPercent: (x) => x.Currency, - newSubscriptionMatrixWithAllocation: (x) => x.Currency, - tieredWithProration: (x) => x.Currency, - newSubscriptionUnitWithProration: (x) => x.Currency, - newSubscriptionGroupedAllocation: (x) => x.Currency, - newSubscriptionBulkWithProration: (x) => x.Currency, - newSubscriptionGroupedWithProratedMinimum: (x) => x.Currency, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.Currency, - groupedWithMinMaxThresholds: (x) => x.Currency, - newSubscriptionMatrixWithDisplayName: (x) => x.Currency, - newSubscriptionGroupedTieredPackage: (x) => x.Currency, - newSubscriptionMaxGroupTieredPackage: (x) => x.Currency, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.Currency, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Currency, - newSubscriptionCumulativeGroupedBulk: (x) => x.Currency, - cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, - newSubscriptionMinimumComposite: (x) => x.Currency, - percent: (x) => x.Currency, - eventOutput: (x) => x.Currency - ); - } + value = this.Value as NewSubscriptionPackagePrice; + return value != null; } - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionMatrix(out var value)) { + /// // `value` is of type `NewSubscriptionMatrixPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionMatrix( + [NotNullWhen(true)] out NewSubscriptionMatrixPrice? value + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.DimensionalPriceConfiguration, - newSubscriptionTiered: (x) => x.DimensionalPriceConfiguration, - newSubscriptionBulk: (x) => x.DimensionalPriceConfiguration, - bulkWithFilters: (x) => x.DimensionalPriceConfiguration, - newSubscriptionPackage: (x) => x.DimensionalPriceConfiguration, - newSubscriptionMatrix: (x) => x.DimensionalPriceConfiguration, - newSubscriptionThresholdTotalAmount: (x) => x.DimensionalPriceConfiguration, - newSubscriptionTieredPackage: (x) => x.DimensionalPriceConfiguration, - newSubscriptionTieredWithMinimum: (x) => x.DimensionalPriceConfiguration, - newSubscriptionGroupedTiered: (x) => x.DimensionalPriceConfiguration, - newSubscriptionTieredPackageWithMinimum: (x) => x.DimensionalPriceConfiguration, - newSubscriptionPackageWithAllocation: (x) => x.DimensionalPriceConfiguration, - newSubscriptionUnitWithPercent: (x) => x.DimensionalPriceConfiguration, - newSubscriptionMatrixWithAllocation: (x) => x.DimensionalPriceConfiguration, - tieredWithProration: (x) => x.DimensionalPriceConfiguration, - newSubscriptionUnitWithProration: (x) => x.DimensionalPriceConfiguration, - newSubscriptionGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - newSubscriptionBulkWithProration: (x) => x.DimensionalPriceConfiguration, - newSubscriptionGroupedWithProratedMinimum: (x) => x.DimensionalPriceConfiguration, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.DimensionalPriceConfiguration, - groupedWithMinMaxThresholds: (x) => x.DimensionalPriceConfiguration, - newSubscriptionMatrixWithDisplayName: (x) => x.DimensionalPriceConfiguration, - newSubscriptionGroupedTieredPackage: (x) => x.DimensionalPriceConfiguration, - newSubscriptionMaxGroupTieredPackage: (x) => x.DimensionalPriceConfiguration, - newSubscriptionScalableMatrixWithUnitPricing: (x) => - x.DimensionalPriceConfiguration, - newSubscriptionScalableMatrixWithTieredPricing: (x) => - x.DimensionalPriceConfiguration, - newSubscriptionCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, - cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, - newSubscriptionMinimumComposite: (x) => x.DimensionalPriceConfiguration, - percent: (x) => x.DimensionalPriceConfiguration, - eventOutput: (x) => x.DimensionalPriceConfiguration - ); - } + value = this.Value as NewSubscriptionMatrixPrice; + return value != null; } - public string? ExternalPriceID + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionThresholdTotalAmount(out var value)) { + /// // `value` is of type `NewSubscriptionThresholdTotalAmountPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionThresholdTotalAmount( + [NotNullWhen(true)] out NewSubscriptionThresholdTotalAmountPrice? value + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.ExternalPriceID, - newSubscriptionTiered: (x) => x.ExternalPriceID, - newSubscriptionBulk: (x) => x.ExternalPriceID, - bulkWithFilters: (x) => x.ExternalPriceID, - newSubscriptionPackage: (x) => x.ExternalPriceID, - newSubscriptionMatrix: (x) => x.ExternalPriceID, - newSubscriptionThresholdTotalAmount: (x) => x.ExternalPriceID, - newSubscriptionTieredPackage: (x) => x.ExternalPriceID, - newSubscriptionTieredWithMinimum: (x) => x.ExternalPriceID, - newSubscriptionGroupedTiered: (x) => x.ExternalPriceID, - newSubscriptionTieredPackageWithMinimum: (x) => x.ExternalPriceID, - newSubscriptionPackageWithAllocation: (x) => x.ExternalPriceID, - newSubscriptionUnitWithPercent: (x) => x.ExternalPriceID, - newSubscriptionMatrixWithAllocation: (x) => x.ExternalPriceID, - tieredWithProration: (x) => x.ExternalPriceID, - newSubscriptionUnitWithProration: (x) => x.ExternalPriceID, - newSubscriptionGroupedAllocation: (x) => x.ExternalPriceID, - newSubscriptionBulkWithProration: (x) => x.ExternalPriceID, - newSubscriptionGroupedWithProratedMinimum: (x) => x.ExternalPriceID, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.ExternalPriceID, - groupedWithMinMaxThresholds: (x) => x.ExternalPriceID, - newSubscriptionMatrixWithDisplayName: (x) => x.ExternalPriceID, - newSubscriptionGroupedTieredPackage: (x) => x.ExternalPriceID, - newSubscriptionMaxGroupTieredPackage: (x) => x.ExternalPriceID, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ExternalPriceID, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, - newSubscriptionCumulativeGroupedBulk: (x) => x.ExternalPriceID, - cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, - newSubscriptionMinimumComposite: (x) => x.ExternalPriceID, - percent: (x) => x.ExternalPriceID, - eventOutput: (x) => x.ExternalPriceID - ); - } + value = this.Value as NewSubscriptionThresholdTotalAmountPrice; + return value != null; } - public double? FixedPriceQuantity + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionTieredPackage(out var value)) { + /// // `value` is of type `NewSubscriptionTieredPackagePrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionTieredPackage( + [NotNullWhen(true)] out NewSubscriptionTieredPackagePrice? value + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.FixedPriceQuantity, - newSubscriptionTiered: (x) => x.FixedPriceQuantity, - newSubscriptionBulk: (x) => x.FixedPriceQuantity, - bulkWithFilters: (x) => x.FixedPriceQuantity, - newSubscriptionPackage: (x) => x.FixedPriceQuantity, - newSubscriptionMatrix: (x) => x.FixedPriceQuantity, - newSubscriptionThresholdTotalAmount: (x) => x.FixedPriceQuantity, - newSubscriptionTieredPackage: (x) => x.FixedPriceQuantity, - newSubscriptionTieredWithMinimum: (x) => x.FixedPriceQuantity, - newSubscriptionGroupedTiered: (x) => x.FixedPriceQuantity, - newSubscriptionTieredPackageWithMinimum: (x) => x.FixedPriceQuantity, - newSubscriptionPackageWithAllocation: (x) => x.FixedPriceQuantity, - newSubscriptionUnitWithPercent: (x) => x.FixedPriceQuantity, - newSubscriptionMatrixWithAllocation: (x) => x.FixedPriceQuantity, - tieredWithProration: (x) => x.FixedPriceQuantity, - newSubscriptionUnitWithProration: (x) => x.FixedPriceQuantity, - newSubscriptionGroupedAllocation: (x) => x.FixedPriceQuantity, - newSubscriptionBulkWithProration: (x) => x.FixedPriceQuantity, - newSubscriptionGroupedWithProratedMinimum: (x) => x.FixedPriceQuantity, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.FixedPriceQuantity, - groupedWithMinMaxThresholds: (x) => x.FixedPriceQuantity, - newSubscriptionMatrixWithDisplayName: (x) => x.FixedPriceQuantity, - newSubscriptionGroupedTieredPackage: (x) => x.FixedPriceQuantity, - newSubscriptionMaxGroupTieredPackage: (x) => x.FixedPriceQuantity, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.FixedPriceQuantity, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, - newSubscriptionCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, - cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, - newSubscriptionMinimumComposite: (x) => x.FixedPriceQuantity, - percent: (x) => x.FixedPriceQuantity, - eventOutput: (x) => x.FixedPriceQuantity - ); - } + value = this.Value as NewSubscriptionTieredPackagePrice; + return value != null; } - public string? InvoiceGroupingKey + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionTieredWithMinimum(out var value)) { + /// // `value` is of type `NewSubscriptionTieredWithMinimumPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionTieredWithMinimum( + [NotNullWhen(true)] out NewSubscriptionTieredWithMinimumPrice? value + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.InvoiceGroupingKey, - newSubscriptionTiered: (x) => x.InvoiceGroupingKey, - newSubscriptionBulk: (x) => x.InvoiceGroupingKey, - bulkWithFilters: (x) => x.InvoiceGroupingKey, - newSubscriptionPackage: (x) => x.InvoiceGroupingKey, - newSubscriptionMatrix: (x) => x.InvoiceGroupingKey, - newSubscriptionThresholdTotalAmount: (x) => x.InvoiceGroupingKey, - newSubscriptionTieredPackage: (x) => x.InvoiceGroupingKey, - newSubscriptionTieredWithMinimum: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedTiered: (x) => x.InvoiceGroupingKey, - newSubscriptionTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, - newSubscriptionPackageWithAllocation: (x) => x.InvoiceGroupingKey, - newSubscriptionUnitWithPercent: (x) => x.InvoiceGroupingKey, - newSubscriptionMatrixWithAllocation: (x) => x.InvoiceGroupingKey, - tieredWithProration: (x) => x.InvoiceGroupingKey, - newSubscriptionUnitWithProration: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedAllocation: (x) => x.InvoiceGroupingKey, - newSubscriptionBulkWithProration: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.InvoiceGroupingKey, - groupedWithMinMaxThresholds: (x) => x.InvoiceGroupingKey, - newSubscriptionMatrixWithDisplayName: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedTieredPackage: (x) => x.InvoiceGroupingKey, - newSubscriptionMaxGroupTieredPackage: (x) => x.InvoiceGroupingKey, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, - newSubscriptionCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, - cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, - newSubscriptionMinimumComposite: (x) => x.InvoiceGroupingKey, - percent: (x) => x.InvoiceGroupingKey, - eventOutput: (x) => x.InvoiceGroupingKey - ); - } + value = this.Value as NewSubscriptionTieredWithMinimumPrice; + return value != null; } - public NewBillingCycleConfiguration? InvoicingCycleConfiguration + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionGroupedTiered(out var value)) { + /// // `value` is of type `NewSubscriptionGroupedTieredPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionGroupedTiered( + [NotNullWhen(true)] out NewSubscriptionGroupedTieredPrice? value + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.InvoicingCycleConfiguration, - newSubscriptionTiered: (x) => x.InvoicingCycleConfiguration, - newSubscriptionBulk: (x) => x.InvoicingCycleConfiguration, - bulkWithFilters: (x) => x.InvoicingCycleConfiguration, - newSubscriptionPackage: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMatrix: (x) => x.InvoicingCycleConfiguration, - newSubscriptionThresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, - newSubscriptionTieredPackage: (x) => x.InvoicingCycleConfiguration, - newSubscriptionTieredWithMinimum: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedTiered: (x) => x.InvoicingCycleConfiguration, - newSubscriptionTieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, - newSubscriptionPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, - newSubscriptionUnitWithPercent: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, - tieredWithProration: (x) => x.InvoicingCycleConfiguration, - newSubscriptionUnitWithProration: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - newSubscriptionBulkWithProration: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedWithProratedMinimum: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.InvoicingCycleConfiguration, - groupedWithMinMaxThresholds: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMatrixWithDisplayName: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedTieredPackage: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMaxGroupTieredPackage: (x) => x.InvoicingCycleConfiguration, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.InvoicingCycleConfiguration, - newSubscriptionScalableMatrixWithTieredPricing: (x) => - x.InvoicingCycleConfiguration, - newSubscriptionCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, - cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMinimumComposite: (x) => x.InvoicingCycleConfiguration, - percent: (x) => x.InvoicingCycleConfiguration, - eventOutput: (x) => x.InvoicingCycleConfiguration - ); - } + value = this.Value as NewSubscriptionGroupedTieredPrice; + return value != null; } - public string? ReferenceID + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionTieredPackageWithMinimum(out var value)) { + /// // `value` is of type `NewSubscriptionTieredPackageWithMinimumPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionTieredPackageWithMinimum( + [NotNullWhen(true)] out NewSubscriptionTieredPackageWithMinimumPrice? value + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.ReferenceID, - newSubscriptionTiered: (x) => x.ReferenceID, - newSubscriptionBulk: (x) => x.ReferenceID, - bulkWithFilters: (x) => x.ReferenceID, - newSubscriptionPackage: (x) => x.ReferenceID, - newSubscriptionMatrix: (x) => x.ReferenceID, - newSubscriptionThresholdTotalAmount: (x) => x.ReferenceID, - newSubscriptionTieredPackage: (x) => x.ReferenceID, - newSubscriptionTieredWithMinimum: (x) => x.ReferenceID, - newSubscriptionGroupedTiered: (x) => x.ReferenceID, - newSubscriptionTieredPackageWithMinimum: (x) => x.ReferenceID, - newSubscriptionPackageWithAllocation: (x) => x.ReferenceID, - newSubscriptionUnitWithPercent: (x) => x.ReferenceID, - newSubscriptionMatrixWithAllocation: (x) => x.ReferenceID, - tieredWithProration: (x) => x.ReferenceID, - newSubscriptionUnitWithProration: (x) => x.ReferenceID, - newSubscriptionGroupedAllocation: (x) => x.ReferenceID, - newSubscriptionBulkWithProration: (x) => x.ReferenceID, - newSubscriptionGroupedWithProratedMinimum: (x) => x.ReferenceID, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.ReferenceID, - groupedWithMinMaxThresholds: (x) => x.ReferenceID, - newSubscriptionMatrixWithDisplayName: (x) => x.ReferenceID, - newSubscriptionGroupedTieredPackage: (x) => x.ReferenceID, - newSubscriptionMaxGroupTieredPackage: (x) => x.ReferenceID, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ReferenceID, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ReferenceID, - newSubscriptionCumulativeGroupedBulk: (x) => x.ReferenceID, - cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, - newSubscriptionMinimumComposite: (x) => x.ReferenceID, - percent: (x) => x.ReferenceID, - eventOutput: (x) => x.ReferenceID - ); - } + value = this.Value as NewSubscriptionTieredPackageWithMinimumPrice; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionUnitPrice value, - JsonElement? element = null + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionPackageWithAllocation(out var value)) { + /// // `value` is of type `NewSubscriptionPackageWithAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionPackageWithAllocation( + [NotNullWhen(true)] out NewSubscriptionPackageWithAllocationPrice? value ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionPackageWithAllocationPrice; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredPrice value, - JsonElement? element = null + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionUnitWithPercent(out var value)) { + /// // `value` is of type `NewSubscriptionUnitWithPercentPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionUnitWithPercent( + [NotNullWhen(true)] out NewSubscriptionUnitWithPercentPrice? value ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionUnitWithPercentPrice; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionBulkPrice value, - JsonElement? element = null + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionMatrixWithAllocation(out var value)) { + /// // `value` is of type `NewSubscriptionMatrixWithAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionMatrixWithAllocation( + [NotNullWhen(true)] out NewSubscriptionMatrixWithAllocationPrice? value ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionMatrixWithAllocationPrice; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value, - JsonElement? element = null + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTieredWithProration(out var value)) { + /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredWithProration( + [NotNullWhen(true)] + out SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration? value ) { - this.Value = value; - this._element = element; + value = + this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionPackagePrice value, - JsonElement? element = null + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionUnitWithProration(out var value)) { + /// // `value` is of type `NewSubscriptionUnitWithProrationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionUnitWithProration( + [NotNullWhen(true)] out NewSubscriptionUnitWithProrationPrice? value ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionUnitWithProrationPrice; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMatrixPrice value, - JsonElement? element = null + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionGroupedAllocation(out var value)) { + /// // `value` is of type `NewSubscriptionGroupedAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionGroupedAllocation( + [NotNullWhen(true)] out NewSubscriptionGroupedAllocationPrice? value ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionGroupedAllocationPrice; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionThresholdTotalAmountPrice value, - JsonElement? element = null + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionBulkWithProration(out var value)) { + /// // `value` is of type `NewSubscriptionBulkWithProrationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionBulkWithProration( + [NotNullWhen(true)] out NewSubscriptionBulkWithProrationPrice? value ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionBulkWithProrationPrice; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredPackagePrice value, - JsonElement? element = null + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionGroupedWithProratedMinimum(out var value)) { + /// // `value` is of type `NewSubscriptionGroupedWithProratedMinimumPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionGroupedWithProratedMinimum( + [NotNullWhen(true)] out NewSubscriptionGroupedWithProratedMinimumPrice? value ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionGroupedWithProratedMinimumPrice; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredWithMinimumPrice value, - JsonElement? element = null + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionGroupedWithMeteredMinimum(out var value)) { + /// // `value` is of type `NewSubscriptionGroupedWithMeteredMinimumPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionGroupedWithMeteredMinimum( + [NotNullWhen(true)] out NewSubscriptionGroupedWithMeteredMinimumPrice? value ) { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedTieredPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredPackageWithMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionPackageWithAllocationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionUnitWithPercentPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMatrixWithAllocationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionUnitWithProrationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedAllocationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionBulkWithProrationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedWithProratedMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedWithMeteredMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMatrixWithDisplayNamePrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedTieredPackagePrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMaxGroupTieredPackagePrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionScalableMatrixWithUnitPricingPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionScalableMatrixWithTieredPricingPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionCumulativeGroupedBulkPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMinimumCompositePrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice(JsonElement element) - { - this._element = element; + value = this.Value as NewSubscriptionGroupedWithMeteredMinimumPrice; + return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionUnit(out var value)) { - /// // `value` is of type `NewSubscriptionUnitPrice` + /// if (instance.TryPickGroupedWithMinMaxThresholds(out var value)) { + /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionUnit([NotNullWhen(true)] out NewSubscriptionUnitPrice? value) + public bool TryPickGroupedWithMinMaxThresholds( + [NotNullWhen(true)] + out SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds? value + ) { - value = this.Value as NewSubscriptionUnitPrice; + value = + this.Value + as SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionTiered(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPrice` + /// if (instance.TryPickNewSubscriptionMatrixWithDisplayName(out var value)) { + /// // `value` is of type `NewSubscriptionMatrixWithDisplayNamePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionTiered( - [NotNullWhen(true)] out NewSubscriptionTieredPrice? value + public bool TryPickNewSubscriptionMatrixWithDisplayName( + [NotNullWhen(true)] out NewSubscriptionMatrixWithDisplayNamePrice? value ) { - value = this.Value as NewSubscriptionTieredPrice; + value = this.Value as NewSubscriptionMatrixWithDisplayNamePrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionBulk(out var value)) { - /// // `value` is of type `NewSubscriptionBulkPrice` + /// if (instance.TryPickNewSubscriptionGroupedTieredPackage(out var value)) { + /// // `value` is of type `NewSubscriptionGroupedTieredPackagePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionBulk([NotNullWhen(true)] out NewSubscriptionBulkPrice? value) + public bool TryPickNewSubscriptionGroupedTieredPackage( + [NotNullWhen(true)] out NewSubscriptionGroupedTieredPackagePrice? value + ) { - value = this.Value as NewSubscriptionBulkPrice; + value = this.Value as NewSubscriptionGroupedTieredPackagePrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickBulkWithFilters(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters` + /// if (instance.TryPickNewSubscriptionMaxGroupTieredPackage(out var value)) { + /// // `value` is of type `NewSubscriptionMaxGroupTieredPackagePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickBulkWithFilters( - [NotNullWhen(true)] - out SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters? value - ) - { - value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionPackage(out var value)) { - /// // `value` is of type `NewSubscriptionPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionPackage( - [NotNullWhen(true)] out NewSubscriptionPackagePrice? value - ) - { - value = this.Value as NewSubscriptionPackagePrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionMatrix(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMatrix( - [NotNullWhen(true)] out NewSubscriptionMatrixPrice? value + public bool TryPickNewSubscriptionMaxGroupTieredPackage( + [NotNullWhen(true)] out NewSubscriptionMaxGroupTieredPackagePrice? value ) { - value = this.Value as NewSubscriptionMatrixPrice; + value = this.Value as NewSubscriptionMaxGroupTieredPackagePrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionThresholdTotalAmount(out var value)) { - /// // `value` is of type `NewSubscriptionThresholdTotalAmountPrice` + /// if (instance.TryPickNewSubscriptionScalableMatrixWithUnitPricing(out var value)) { + /// // `value` is of type `NewSubscriptionScalableMatrixWithUnitPricingPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionThresholdTotalAmount( - [NotNullWhen(true)] out NewSubscriptionThresholdTotalAmountPrice? value + public bool TryPickNewSubscriptionScalableMatrixWithUnitPricing( + [NotNullWhen(true)] out NewSubscriptionScalableMatrixWithUnitPricingPrice? value ) { - value = this.Value as NewSubscriptionThresholdTotalAmountPrice; + value = this.Value as NewSubscriptionScalableMatrixWithUnitPricingPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionTieredPackage(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPackagePrice` + /// if (instance.TryPickNewSubscriptionScalableMatrixWithTieredPricing(out var value)) { + /// // `value` is of type `NewSubscriptionScalableMatrixWithTieredPricingPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionTieredPackage( - [NotNullWhen(true)] out NewSubscriptionTieredPackagePrice? value + public bool TryPickNewSubscriptionScalableMatrixWithTieredPricing( + [NotNullWhen(true)] out NewSubscriptionScalableMatrixWithTieredPricingPrice? value ) { - value = this.Value as NewSubscriptionTieredPackagePrice; + value = this.Value as NewSubscriptionScalableMatrixWithTieredPricingPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionTieredWithMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionTieredWithMinimumPrice` + /// if (instance.TryPickNewSubscriptionCumulativeGroupedBulk(out var value)) { + /// // `value` is of type `NewSubscriptionCumulativeGroupedBulkPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionTieredWithMinimum( - [NotNullWhen(true)] out NewSubscriptionTieredWithMinimumPrice? value + public bool TryPickNewSubscriptionCumulativeGroupedBulk( + [NotNullWhen(true)] out NewSubscriptionCumulativeGroupedBulkPrice? value ) { - value = this.Value as NewSubscriptionTieredWithMinimumPrice; + value = this.Value as NewSubscriptionCumulativeGroupedBulkPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionGroupedTiered(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedTieredPrice` + /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { + /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionGroupedTiered( - [NotNullWhen(true)] out NewSubscriptionGroupedTieredPrice? value + public bool TryPickCumulativeGroupedAllocation( + [NotNullWhen(true)] + out SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation? value ) { - value = this.Value as NewSubscriptionGroupedTieredPrice; + value = + this.Value + as SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionTieredPackageWithMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPackageWithMinimumPrice` + /// if (instance.TryPickNewSubscriptionMinimumComposite(out var value)) { + /// // `value` is of type `NewSubscriptionMinimumCompositePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionTieredPackageWithMinimum( - [NotNullWhen(true)] out NewSubscriptionTieredPackageWithMinimumPrice? value + public bool TryPickNewSubscriptionMinimumComposite( + [NotNullWhen(true)] out NewSubscriptionMinimumCompositePrice? value ) { - value = this.Value as NewSubscriptionTieredPackageWithMinimumPrice; + value = this.Value as NewSubscriptionMinimumCompositePrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionPackageWithAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionPackageWithAllocationPrice` + /// if (instance.TryPickPercent(out var value)) { + /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePricePercent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionPackageWithAllocation( - [NotNullWhen(true)] out NewSubscriptionPackageWithAllocationPrice? value + public bool TryPickPercent( + [NotNullWhen(true)] out SubscriptionSchedulePlanChangeParamsReplacePricePricePercent? value ) { - value = this.Value as NewSubscriptionPackageWithAllocationPrice; + value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePricePercent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionUnitWithPercent(out var value)) { - /// // `value` is of type `NewSubscriptionUnitWithPercentPrice` + /// if (instance.TryPickEventOutput(out var value)) { + /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionUnitWithPercent( - [NotNullWhen(true)] out NewSubscriptionUnitWithPercentPrice? value + public bool TryPickEventOutput( + [NotNullWhen(true)] + out SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput? value ) { - value = this.Value as NewSubscriptionUnitWithPercentPrice; + value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput; return value != null; } /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. + /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// - /// - /// if (instance.TryPickNewSubscriptionMatrixWithAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixWithAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMatrixWithAllocation( - [NotNullWhen(true)] out NewSubscriptionMatrixWithAllocationPrice? value - ) - { - value = this.Value as NewSubscriptionMatrixWithAllocationPrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. /// - /// Consider using or if you need to handle every variant. + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// /// /// /// - /// if (instance.TryPickTieredWithProration(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration` - /// Console.WriteLine(value); - /// } + /// instance.Switch( + /// (NewSubscriptionUnitPrice value) => {...}, + /// (NewSubscriptionTieredPrice value) => {...}, + /// (NewSubscriptionBulkPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value) => {...}, + /// (NewSubscriptionPackagePrice value) => {...}, + /// (NewSubscriptionMatrixPrice value) => {...}, + /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, + /// (NewSubscriptionTieredPackagePrice value) => {...}, + /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedTieredPrice value) => {...}, + /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, + /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, + /// (NewSubscriptionUnitWithPercentPrice value) => {...}, + /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value) => {...}, + /// (NewSubscriptionUnitWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedAllocationPrice value) => {...}, + /// (NewSubscriptionBulkWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, + /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, + /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value) => {...}, + /// (NewSubscriptionMinimumCompositePrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value) => {...} + /// ); /// /// /// - public bool TryPickTieredWithProration( - [NotNullWhen(true)] - out SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration? value + public void Switch( + System::Action newSubscriptionUnit, + System::Action newSubscriptionTiered, + System::Action newSubscriptionBulk, + System::Action bulkWithFilters, + System::Action newSubscriptionPackage, + System::Action newSubscriptionMatrix, + System::Action newSubscriptionThresholdTotalAmount, + System::Action newSubscriptionTieredPackage, + System::Action newSubscriptionTieredWithMinimum, + System::Action newSubscriptionGroupedTiered, + System::Action newSubscriptionTieredPackageWithMinimum, + System::Action newSubscriptionPackageWithAllocation, + System::Action newSubscriptionUnitWithPercent, + System::Action newSubscriptionMatrixWithAllocation, + System::Action tieredWithProration, + System::Action newSubscriptionUnitWithProration, + System::Action newSubscriptionGroupedAllocation, + System::Action newSubscriptionBulkWithProration, + System::Action newSubscriptionGroupedWithProratedMinimum, + System::Action newSubscriptionGroupedWithMeteredMinimum, + System::Action groupedWithMinMaxThresholds, + System::Action newSubscriptionMatrixWithDisplayName, + System::Action newSubscriptionGroupedTieredPackage, + System::Action newSubscriptionMaxGroupTieredPackage, + System::Action newSubscriptionScalableMatrixWithUnitPricing, + System::Action newSubscriptionScalableMatrixWithTieredPricing, + System::Action newSubscriptionCumulativeGroupedBulk, + System::Action cumulativeGroupedAllocation, + System::Action newSubscriptionMinimumComposite, + System::Action percent, + System::Action eventOutput ) { - value = - this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionUnitWithProration(out var value)) { - /// // `value` is of type `NewSubscriptionUnitWithProrationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionUnitWithProration( - [NotNullWhen(true)] out NewSubscriptionUnitWithProrationPrice? value - ) - { - value = this.Value as NewSubscriptionUnitWithProrationPrice; - return value != null; + switch (this.Value) + { + case NewSubscriptionUnitPrice value: + newSubscriptionUnit(value); + break; + case NewSubscriptionTieredPrice value: + newSubscriptionTiered(value); + break; + case NewSubscriptionBulkPrice value: + newSubscriptionBulk(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value: + bulkWithFilters(value); + break; + case NewSubscriptionPackagePrice value: + newSubscriptionPackage(value); + break; + case NewSubscriptionMatrixPrice value: + newSubscriptionMatrix(value); + break; + case NewSubscriptionThresholdTotalAmountPrice value: + newSubscriptionThresholdTotalAmount(value); + break; + case NewSubscriptionTieredPackagePrice value: + newSubscriptionTieredPackage(value); + break; + case NewSubscriptionTieredWithMinimumPrice value: + newSubscriptionTieredWithMinimum(value); + break; + case NewSubscriptionGroupedTieredPrice value: + newSubscriptionGroupedTiered(value); + break; + case NewSubscriptionTieredPackageWithMinimumPrice value: + newSubscriptionTieredPackageWithMinimum(value); + break; + case NewSubscriptionPackageWithAllocationPrice value: + newSubscriptionPackageWithAllocation(value); + break; + case NewSubscriptionUnitWithPercentPrice value: + newSubscriptionUnitWithPercent(value); + break; + case NewSubscriptionMatrixWithAllocationPrice value: + newSubscriptionMatrixWithAllocation(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value: + tieredWithProration(value); + break; + case NewSubscriptionUnitWithProrationPrice value: + newSubscriptionUnitWithProration(value); + break; + case NewSubscriptionGroupedAllocationPrice value: + newSubscriptionGroupedAllocation(value); + break; + case NewSubscriptionBulkWithProrationPrice value: + newSubscriptionBulkWithProration(value); + break; + case NewSubscriptionGroupedWithProratedMinimumPrice value: + newSubscriptionGroupedWithProratedMinimum(value); + break; + case NewSubscriptionGroupedWithMeteredMinimumPrice value: + newSubscriptionGroupedWithMeteredMinimum(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value: + groupedWithMinMaxThresholds(value); + break; + case NewSubscriptionMatrixWithDisplayNamePrice value: + newSubscriptionMatrixWithDisplayName(value); + break; + case NewSubscriptionGroupedTieredPackagePrice value: + newSubscriptionGroupedTieredPackage(value); + break; + case NewSubscriptionMaxGroupTieredPackagePrice value: + newSubscriptionMaxGroupTieredPackage(value); + break; + case NewSubscriptionScalableMatrixWithUnitPricingPrice value: + newSubscriptionScalableMatrixWithUnitPricing(value); + break; + case NewSubscriptionScalableMatrixWithTieredPricingPrice value: + newSubscriptionScalableMatrixWithTieredPricing(value); + break; + case NewSubscriptionCumulativeGroupedBulkPrice value: + newSubscriptionCumulativeGroupedBulk(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value: + cumulativeGroupedAllocation(value); + break; + case NewSubscriptionMinimumCompositePrice value: + newSubscriptionMinimumComposite(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value: + percent(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value: + eventOutput(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePrice" + ); + } } /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. /// - /// Consider using or if you need to handle every variant. + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// /// /// /// - /// if (instance.TryPickNewSubscriptionGroupedAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedAllocationPrice` - /// Console.WriteLine(value); - /// } + /// var result = instance.Match( + /// (NewSubscriptionUnitPrice value) => {...}, + /// (NewSubscriptionTieredPrice value) => {...}, + /// (NewSubscriptionBulkPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value) => {...}, + /// (NewSubscriptionPackagePrice value) => {...}, + /// (NewSubscriptionMatrixPrice value) => {...}, + /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, + /// (NewSubscriptionTieredPackagePrice value) => {...}, + /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedTieredPrice value) => {...}, + /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, + /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, + /// (NewSubscriptionUnitWithPercentPrice value) => {...}, + /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value) => {...}, + /// (NewSubscriptionUnitWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedAllocationPrice value) => {...}, + /// (NewSubscriptionBulkWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, + /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, + /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value) => {...}, + /// (NewSubscriptionMinimumCompositePrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value) => {...} + /// ); /// /// /// - public bool TryPickNewSubscriptionGroupedAllocation( - [NotNullWhen(true)] out NewSubscriptionGroupedAllocationPrice? value + public T Match( + System::Func newSubscriptionUnit, + System::Func newSubscriptionTiered, + System::Func newSubscriptionBulk, + System::Func< + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters, + T + > bulkWithFilters, + System::Func newSubscriptionPackage, + System::Func newSubscriptionMatrix, + System::Func< + NewSubscriptionThresholdTotalAmountPrice, + T + > newSubscriptionThresholdTotalAmount, + System::Func newSubscriptionTieredPackage, + System::Func newSubscriptionTieredWithMinimum, + System::Func newSubscriptionGroupedTiered, + System::Func< + NewSubscriptionTieredPackageWithMinimumPrice, + T + > newSubscriptionTieredPackageWithMinimum, + System::Func< + NewSubscriptionPackageWithAllocationPrice, + T + > newSubscriptionPackageWithAllocation, + System::Func newSubscriptionUnitWithPercent, + System::Func< + NewSubscriptionMatrixWithAllocationPrice, + T + > newSubscriptionMatrixWithAllocation, + System::Func< + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration, + T + > tieredWithProration, + System::Func newSubscriptionUnitWithProration, + System::Func newSubscriptionGroupedAllocation, + System::Func newSubscriptionBulkWithProration, + System::Func< + NewSubscriptionGroupedWithProratedMinimumPrice, + T + > newSubscriptionGroupedWithProratedMinimum, + System::Func< + NewSubscriptionGroupedWithMeteredMinimumPrice, + T + > newSubscriptionGroupedWithMeteredMinimum, + System::Func< + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds, + T + > groupedWithMinMaxThresholds, + System::Func< + NewSubscriptionMatrixWithDisplayNamePrice, + T + > newSubscriptionMatrixWithDisplayName, + System::Func< + NewSubscriptionGroupedTieredPackagePrice, + T + > newSubscriptionGroupedTieredPackage, + System::Func< + NewSubscriptionMaxGroupTieredPackagePrice, + T + > newSubscriptionMaxGroupTieredPackage, + System::Func< + NewSubscriptionScalableMatrixWithUnitPricingPrice, + T + > newSubscriptionScalableMatrixWithUnitPricing, + System::Func< + NewSubscriptionScalableMatrixWithTieredPricingPrice, + T + > newSubscriptionScalableMatrixWithTieredPricing, + System::Func< + NewSubscriptionCumulativeGroupedBulkPrice, + T + > newSubscriptionCumulativeGroupedBulk, + System::Func< + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation, + T + > cumulativeGroupedAllocation, + System::Func newSubscriptionMinimumComposite, + System::Func percent, + System::Func< + SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput, + T + > eventOutput ) { - value = this.Value as NewSubscriptionGroupedAllocationPrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionBulkWithProration(out var value)) { - /// // `value` is of type `NewSubscriptionBulkWithProrationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionBulkWithProration( - [NotNullWhen(true)] out NewSubscriptionBulkWithProrationPrice? value - ) - { - value = this.Value as NewSubscriptionBulkWithProrationPrice; - return value != null; + return this.Value switch + { + NewSubscriptionUnitPrice value => newSubscriptionUnit(value), + NewSubscriptionTieredPrice value => newSubscriptionTiered(value), + NewSubscriptionBulkPrice value => newSubscriptionBulk(value), + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value => + bulkWithFilters(value), + NewSubscriptionPackagePrice value => newSubscriptionPackage(value), + NewSubscriptionMatrixPrice value => newSubscriptionMatrix(value), + NewSubscriptionThresholdTotalAmountPrice value => newSubscriptionThresholdTotalAmount( + value + ), + NewSubscriptionTieredPackagePrice value => newSubscriptionTieredPackage(value), + NewSubscriptionTieredWithMinimumPrice value => newSubscriptionTieredWithMinimum(value), + NewSubscriptionGroupedTieredPrice value => newSubscriptionGroupedTiered(value), + NewSubscriptionTieredPackageWithMinimumPrice value => + newSubscriptionTieredPackageWithMinimum(value), + NewSubscriptionPackageWithAllocationPrice value => newSubscriptionPackageWithAllocation( + value + ), + NewSubscriptionUnitWithPercentPrice value => newSubscriptionUnitWithPercent(value), + NewSubscriptionMatrixWithAllocationPrice value => newSubscriptionMatrixWithAllocation( + value + ), + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value => + tieredWithProration(value), + NewSubscriptionUnitWithProrationPrice value => newSubscriptionUnitWithProration(value), + NewSubscriptionGroupedAllocationPrice value => newSubscriptionGroupedAllocation(value), + NewSubscriptionBulkWithProrationPrice value => newSubscriptionBulkWithProration(value), + NewSubscriptionGroupedWithProratedMinimumPrice value => + newSubscriptionGroupedWithProratedMinimum(value), + NewSubscriptionGroupedWithMeteredMinimumPrice value => + newSubscriptionGroupedWithMeteredMinimum(value), + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value => + groupedWithMinMaxThresholds(value), + NewSubscriptionMatrixWithDisplayNamePrice value => newSubscriptionMatrixWithDisplayName( + value + ), + NewSubscriptionGroupedTieredPackagePrice value => newSubscriptionGroupedTieredPackage( + value + ), + NewSubscriptionMaxGroupTieredPackagePrice value => newSubscriptionMaxGroupTieredPackage( + value + ), + NewSubscriptionScalableMatrixWithUnitPricingPrice value => + newSubscriptionScalableMatrixWithUnitPricing(value), + NewSubscriptionScalableMatrixWithTieredPricingPrice value => + newSubscriptionScalableMatrixWithTieredPricing(value), + NewSubscriptionCumulativeGroupedBulkPrice value => newSubscriptionCumulativeGroupedBulk( + value + ), + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value => + cumulativeGroupedAllocation(value), + NewSubscriptionMinimumCompositePrice value => newSubscriptionMinimumComposite(value), + SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value => percent(value), + SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value => eventOutput( + value + ), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePrice" + ), + }; } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionGroupedWithProratedMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedWithProratedMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionGroupedWithProratedMinimum( - [NotNullWhen(true)] out NewSubscriptionGroupedWithProratedMinimumPrice? value - ) - { - value = this.Value as NewSubscriptionGroupedWithProratedMinimumPrice; - return value != null; - } + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionUnitPrice value + ) => new(value); - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionGroupedWithMeteredMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedWithMeteredMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionGroupedWithMeteredMinimum( - [NotNullWhen(true)] out NewSubscriptionGroupedWithMeteredMinimumPrice? value - ) - { - value = this.Value as NewSubscriptionGroupedWithMeteredMinimumPrice; - return value != null; - } + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredPrice value + ) => new(value); - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickGroupedWithMinMaxThresholds(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] - out SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds? value - ) - { - value = - this.Value - as SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds; - return value != null; - } + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionBulkPrice value + ) => new(value); - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionMatrixWithDisplayName(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixWithDisplayNamePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMatrixWithDisplayName( - [NotNullWhen(true)] out NewSubscriptionMatrixWithDisplayNamePrice? value - ) - { - value = this.Value as NewSubscriptionMatrixWithDisplayNamePrice; - return value != null; - } + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value + ) => new(value); - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionGroupedTieredPackage(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionGroupedTieredPackage( - [NotNullWhen(true)] out NewSubscriptionGroupedTieredPackagePrice? value - ) - { - value = this.Value as NewSubscriptionGroupedTieredPackagePrice; - return value != null; - } + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionPackagePrice value + ) => new(value); - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionMaxGroupTieredPackage(out var value)) { - /// // `value` is of type `NewSubscriptionMaxGroupTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMaxGroupTieredPackage( - [NotNullWhen(true)] out NewSubscriptionMaxGroupTieredPackagePrice? value - ) - { - value = this.Value as NewSubscriptionMaxGroupTieredPackagePrice; - return value != null; - } + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMatrixPrice value + ) => new(value); - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionScalableMatrixWithUnitPricing(out var value)) { - /// // `value` is of type `NewSubscriptionScalableMatrixWithUnitPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionScalableMatrixWithUnitPricing( - [NotNullWhen(true)] out NewSubscriptionScalableMatrixWithUnitPricingPrice? value - ) - { - value = this.Value as NewSubscriptionScalableMatrixWithUnitPricingPrice; - return value != null; - } + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionThresholdTotalAmountPrice value + ) => new(value); - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionScalableMatrixWithTieredPricing(out var value)) { - /// // `value` is of type `NewSubscriptionScalableMatrixWithTieredPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionScalableMatrixWithTieredPricing( - [NotNullWhen(true)] out NewSubscriptionScalableMatrixWithTieredPricingPrice? value - ) - { - value = this.Value as NewSubscriptionScalableMatrixWithTieredPricingPrice; - return value != null; - } + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredPackagePrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredWithMinimumPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedTieredPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredPackageWithMinimumPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionPackageWithAllocationPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionUnitWithPercentPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMatrixWithAllocationPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionUnitWithProrationPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedAllocationPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionBulkWithProrationPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedWithProratedMinimumPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedWithMeteredMinimumPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMatrixWithDisplayNamePrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedTieredPackagePrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMaxGroupTieredPackagePrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionScalableMatrixWithUnitPricingPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionScalableMatrixWithTieredPricingPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionCumulativeGroupedBulkPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMinimumCompositePrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value + ) => new(value); /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). /// - /// Consider using or if you need to handle every variant. + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). /// - /// - /// - /// if (instance.TryPickNewSubscriptionCumulativeGroupedBulk(out var value)) { - /// // `value` is of type `NewSubscriptionCumulativeGroupedBulkPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// + /// Thrown when the instance does not pass validation. + /// /// - public bool TryPickNewSubscriptionCumulativeGroupedBulk( - [NotNullWhen(true)] out NewSubscriptionCumulativeGroupedBulkPrice? value - ) + public override void Validate() { - value = this.Value as NewSubscriptionCumulativeGroupedBulkPrice; - return value != null; + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePrice" + ); + } + this.Switch( + (newSubscriptionUnit) => newSubscriptionUnit.Validate(), + (newSubscriptionTiered) => newSubscriptionTiered.Validate(), + (newSubscriptionBulk) => newSubscriptionBulk.Validate(), + (bulkWithFilters) => bulkWithFilters.Validate(), + (newSubscriptionPackage) => newSubscriptionPackage.Validate(), + (newSubscriptionMatrix) => newSubscriptionMatrix.Validate(), + (newSubscriptionThresholdTotalAmount) => newSubscriptionThresholdTotalAmount.Validate(), + (newSubscriptionTieredPackage) => newSubscriptionTieredPackage.Validate(), + (newSubscriptionTieredWithMinimum) => newSubscriptionTieredWithMinimum.Validate(), + (newSubscriptionGroupedTiered) => newSubscriptionGroupedTiered.Validate(), + (newSubscriptionTieredPackageWithMinimum) => + newSubscriptionTieredPackageWithMinimum.Validate(), + (newSubscriptionPackageWithAllocation) => + newSubscriptionPackageWithAllocation.Validate(), + (newSubscriptionUnitWithPercent) => newSubscriptionUnitWithPercent.Validate(), + (newSubscriptionMatrixWithAllocation) => newSubscriptionMatrixWithAllocation.Validate(), + (tieredWithProration) => tieredWithProration.Validate(), + (newSubscriptionUnitWithProration) => newSubscriptionUnitWithProration.Validate(), + (newSubscriptionGroupedAllocation) => newSubscriptionGroupedAllocation.Validate(), + (newSubscriptionBulkWithProration) => newSubscriptionBulkWithProration.Validate(), + (newSubscriptionGroupedWithProratedMinimum) => + newSubscriptionGroupedWithProratedMinimum.Validate(), + (newSubscriptionGroupedWithMeteredMinimum) => + newSubscriptionGroupedWithMeteredMinimum.Validate(), + (groupedWithMinMaxThresholds) => groupedWithMinMaxThresholds.Validate(), + (newSubscriptionMatrixWithDisplayName) => + newSubscriptionMatrixWithDisplayName.Validate(), + (newSubscriptionGroupedTieredPackage) => newSubscriptionGroupedTieredPackage.Validate(), + (newSubscriptionMaxGroupTieredPackage) => + newSubscriptionMaxGroupTieredPackage.Validate(), + (newSubscriptionScalableMatrixWithUnitPricing) => + newSubscriptionScalableMatrixWithUnitPricing.Validate(), + (newSubscriptionScalableMatrixWithTieredPricing) => + newSubscriptionScalableMatrixWithTieredPricing.Validate(), + (newSubscriptionCumulativeGroupedBulk) => + newSubscriptionCumulativeGroupedBulk.Validate(), + (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), + (newSubscriptionMinimumComposite) => newSubscriptionMinimumComposite.Validate(), + (percent) => percent.Validate(), + (eventOutput) => eventOutput.Validate() + ); } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] - out SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation? value - ) + public virtual bool Equals(SubscriptionSchedulePlanChangeParamsReplacePricePrice? other) { - value = - this.Value - as SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation; - return value != null; + return other != null && JsonElement.DeepEquals(this.Json, other.Json); } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum( - [NotNullWhen(true)] out SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum? value - ) + public override int GetHashCode() { - value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum; - return value != null; + return 0; } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionMinimumComposite(out var value)) { - /// // `value` is of type `NewSubscriptionMinimumCompositePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMinimumComposite( - [NotNullWhen(true)] out NewSubscriptionMinimumCompositePrice? value + public override string ToString() => + JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +} + +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceConverter + : JsonConverter +{ + public override SubscriptionSchedulePlanChangeParamsReplacePricePrice? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - value = this.Value as NewSubscriptionMinimumCompositePrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickPercent(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePricePercent` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickPercent( - [NotNullWhen(true)] out SubscriptionSchedulePlanChangeParamsReplacePricePricePercent? value - ) - { - value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePricePercent; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickEventOutput(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickEventOutput( - [NotNullWhen(true)] - out SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput? value - ) - { - value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput; - return value != null; - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (NewSubscriptionUnitPrice value) => {...}, - /// (NewSubscriptionTieredPrice value) => {...}, - /// (NewSubscriptionBulkPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value) => {...}, - /// (NewSubscriptionPackagePrice value) => {...}, - /// (NewSubscriptionMatrixPrice value) => {...}, - /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, - /// (NewSubscriptionTieredPackagePrice value) => {...}, - /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedTieredPrice value) => {...}, - /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, - /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, - /// (NewSubscriptionUnitWithPercentPrice value) => {...}, - /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value) => {...}, - /// (NewSubscriptionUnitWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedAllocationPrice value) => {...}, - /// (NewSubscriptionBulkWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, - /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, - /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value) => {...}, - /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action newSubscriptionUnit, - System::Action newSubscriptionTiered, - System::Action newSubscriptionBulk, - System::Action bulkWithFilters, - System::Action newSubscriptionPackage, - System::Action newSubscriptionMatrix, - System::Action newSubscriptionThresholdTotalAmount, - System::Action newSubscriptionTieredPackage, - System::Action newSubscriptionTieredWithMinimum, - System::Action newSubscriptionGroupedTiered, - System::Action newSubscriptionTieredPackageWithMinimum, - System::Action newSubscriptionPackageWithAllocation, - System::Action newSubscriptionUnitWithPercent, - System::Action newSubscriptionMatrixWithAllocation, - System::Action tieredWithProration, - System::Action newSubscriptionUnitWithProration, - System::Action newSubscriptionGroupedAllocation, - System::Action newSubscriptionBulkWithProration, - System::Action newSubscriptionGroupedWithProratedMinimum, - System::Action newSubscriptionGroupedWithMeteredMinimum, - System::Action groupedWithMinMaxThresholds, - System::Action newSubscriptionMatrixWithDisplayName, - System::Action newSubscriptionGroupedTieredPackage, - System::Action newSubscriptionMaxGroupTieredPackage, - System::Action newSubscriptionScalableMatrixWithUnitPricing, - System::Action newSubscriptionScalableMatrixWithTieredPricing, - System::Action newSubscriptionCumulativeGroupedBulk, - System::Action cumulativeGroupedAllocation, - System::Action minimum, - System::Action newSubscriptionMinimumComposite, - System::Action percent, - System::Action eventOutput - ) - { - switch (this.Value) - { - case NewSubscriptionUnitPrice value: - newSubscriptionUnit(value); - break; - case NewSubscriptionTieredPrice value: - newSubscriptionTiered(value); - break; - case NewSubscriptionBulkPrice value: - newSubscriptionBulk(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value: - bulkWithFilters(value); - break; - case NewSubscriptionPackagePrice value: - newSubscriptionPackage(value); - break; - case NewSubscriptionMatrixPrice value: - newSubscriptionMatrix(value); - break; - case NewSubscriptionThresholdTotalAmountPrice value: - newSubscriptionThresholdTotalAmount(value); - break; - case NewSubscriptionTieredPackagePrice value: - newSubscriptionTieredPackage(value); - break; - case NewSubscriptionTieredWithMinimumPrice value: - newSubscriptionTieredWithMinimum(value); - break; - case NewSubscriptionGroupedTieredPrice value: - newSubscriptionGroupedTiered(value); - break; - case NewSubscriptionTieredPackageWithMinimumPrice value: - newSubscriptionTieredPackageWithMinimum(value); - break; - case NewSubscriptionPackageWithAllocationPrice value: - newSubscriptionPackageWithAllocation(value); - break; - case NewSubscriptionUnitWithPercentPrice value: - newSubscriptionUnitWithPercent(value); - break; - case NewSubscriptionMatrixWithAllocationPrice value: - newSubscriptionMatrixWithAllocation(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value: - tieredWithProration(value); - break; - case NewSubscriptionUnitWithProrationPrice value: - newSubscriptionUnitWithProration(value); - break; - case NewSubscriptionGroupedAllocationPrice value: - newSubscriptionGroupedAllocation(value); - break; - case NewSubscriptionBulkWithProrationPrice value: - newSubscriptionBulkWithProration(value); - break; - case NewSubscriptionGroupedWithProratedMinimumPrice value: - newSubscriptionGroupedWithProratedMinimum(value); - break; - case NewSubscriptionGroupedWithMeteredMinimumPrice value: - newSubscriptionGroupedWithMeteredMinimum(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value: - groupedWithMinMaxThresholds(value); - break; - case NewSubscriptionMatrixWithDisplayNamePrice value: - newSubscriptionMatrixWithDisplayName(value); - break; - case NewSubscriptionGroupedTieredPackagePrice value: - newSubscriptionGroupedTieredPackage(value); - break; - case NewSubscriptionMaxGroupTieredPackagePrice value: - newSubscriptionMaxGroupTieredPackage(value); - break; - case NewSubscriptionScalableMatrixWithUnitPricingPrice value: - newSubscriptionScalableMatrixWithUnitPricing(value); - break; - case NewSubscriptionScalableMatrixWithTieredPricingPrice value: - newSubscriptionScalableMatrixWithTieredPricing(value); - break; - case NewSubscriptionCumulativeGroupedBulkPrice value: - newSubscriptionCumulativeGroupedBulk(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value: - cumulativeGroupedAllocation(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value: - minimum(value); - break; - case NewSubscriptionMinimumCompositePrice value: - newSubscriptionMinimumComposite(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value: - percent(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value: - eventOutput(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePrice" - ); - } - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (NewSubscriptionUnitPrice value) => {...}, - /// (NewSubscriptionTieredPrice value) => {...}, - /// (NewSubscriptionBulkPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value) => {...}, - /// (NewSubscriptionPackagePrice value) => {...}, - /// (NewSubscriptionMatrixPrice value) => {...}, - /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, - /// (NewSubscriptionTieredPackagePrice value) => {...}, - /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedTieredPrice value) => {...}, - /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, - /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, - /// (NewSubscriptionUnitWithPercentPrice value) => {...}, - /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value) => {...}, - /// (NewSubscriptionUnitWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedAllocationPrice value) => {...}, - /// (NewSubscriptionBulkWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, - /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, - /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value) => {...}, - /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func newSubscriptionUnit, - System::Func newSubscriptionTiered, - System::Func newSubscriptionBulk, - System::Func< - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters, - T - > bulkWithFilters, - System::Func newSubscriptionPackage, - System::Func newSubscriptionMatrix, - System::Func< - NewSubscriptionThresholdTotalAmountPrice, - T - > newSubscriptionThresholdTotalAmount, - System::Func newSubscriptionTieredPackage, - System::Func newSubscriptionTieredWithMinimum, - System::Func newSubscriptionGroupedTiered, - System::Func< - NewSubscriptionTieredPackageWithMinimumPrice, - T - > newSubscriptionTieredPackageWithMinimum, - System::Func< - NewSubscriptionPackageWithAllocationPrice, - T - > newSubscriptionPackageWithAllocation, - System::Func newSubscriptionUnitWithPercent, - System::Func< - NewSubscriptionMatrixWithAllocationPrice, - T - > newSubscriptionMatrixWithAllocation, - System::Func< - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration, - T - > tieredWithProration, - System::Func newSubscriptionUnitWithProration, - System::Func newSubscriptionGroupedAllocation, - System::Func newSubscriptionBulkWithProration, - System::Func< - NewSubscriptionGroupedWithProratedMinimumPrice, - T - > newSubscriptionGroupedWithProratedMinimum, - System::Func< - NewSubscriptionGroupedWithMeteredMinimumPrice, - T - > newSubscriptionGroupedWithMeteredMinimum, - System::Func< - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds, - T - > groupedWithMinMaxThresholds, - System::Func< - NewSubscriptionMatrixWithDisplayNamePrice, - T - > newSubscriptionMatrixWithDisplayName, - System::Func< - NewSubscriptionGroupedTieredPackagePrice, - T - > newSubscriptionGroupedTieredPackage, - System::Func< - NewSubscriptionMaxGroupTieredPackagePrice, - T - > newSubscriptionMaxGroupTieredPackage, - System::Func< - NewSubscriptionScalableMatrixWithUnitPricingPrice, - T - > newSubscriptionScalableMatrixWithUnitPricing, - System::Func< - NewSubscriptionScalableMatrixWithTieredPricingPrice, - T - > newSubscriptionScalableMatrixWithTieredPricing, - System::Func< - NewSubscriptionCumulativeGroupedBulkPrice, - T - > newSubscriptionCumulativeGroupedBulk, - System::Func< - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation, - T - > cumulativeGroupedAllocation, - System::Func minimum, - System::Func newSubscriptionMinimumComposite, - System::Func percent, - System::Func< - SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput, - T - > eventOutput - ) - { - return this.Value switch - { - NewSubscriptionUnitPrice value => newSubscriptionUnit(value), - NewSubscriptionTieredPrice value => newSubscriptionTiered(value), - NewSubscriptionBulkPrice value => newSubscriptionBulk(value), - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value => - bulkWithFilters(value), - NewSubscriptionPackagePrice value => newSubscriptionPackage(value), - NewSubscriptionMatrixPrice value => newSubscriptionMatrix(value), - NewSubscriptionThresholdTotalAmountPrice value => newSubscriptionThresholdTotalAmount( - value - ), - NewSubscriptionTieredPackagePrice value => newSubscriptionTieredPackage(value), - NewSubscriptionTieredWithMinimumPrice value => newSubscriptionTieredWithMinimum(value), - NewSubscriptionGroupedTieredPrice value => newSubscriptionGroupedTiered(value), - NewSubscriptionTieredPackageWithMinimumPrice value => - newSubscriptionTieredPackageWithMinimum(value), - NewSubscriptionPackageWithAllocationPrice value => newSubscriptionPackageWithAllocation( - value - ), - NewSubscriptionUnitWithPercentPrice value => newSubscriptionUnitWithPercent(value), - NewSubscriptionMatrixWithAllocationPrice value => newSubscriptionMatrixWithAllocation( - value - ), - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value => - tieredWithProration(value), - NewSubscriptionUnitWithProrationPrice value => newSubscriptionUnitWithProration(value), - NewSubscriptionGroupedAllocationPrice value => newSubscriptionGroupedAllocation(value), - NewSubscriptionBulkWithProrationPrice value => newSubscriptionBulkWithProration(value), - NewSubscriptionGroupedWithProratedMinimumPrice value => - newSubscriptionGroupedWithProratedMinimum(value), - NewSubscriptionGroupedWithMeteredMinimumPrice value => - newSubscriptionGroupedWithMeteredMinimum(value), - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value => - groupedWithMinMaxThresholds(value), - NewSubscriptionMatrixWithDisplayNamePrice value => newSubscriptionMatrixWithDisplayName( - value - ), - NewSubscriptionGroupedTieredPackagePrice value => newSubscriptionGroupedTieredPackage( - value - ), - NewSubscriptionMaxGroupTieredPackagePrice value => newSubscriptionMaxGroupTieredPackage( - value - ), - NewSubscriptionScalableMatrixWithUnitPricingPrice value => - newSubscriptionScalableMatrixWithUnitPricing(value), - NewSubscriptionScalableMatrixWithTieredPricingPrice value => - newSubscriptionScalableMatrixWithTieredPricing(value), - NewSubscriptionCumulativeGroupedBulkPrice value => newSubscriptionCumulativeGroupedBulk( - value - ), - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value => - cumulativeGroupedAllocation(value), - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value => minimum(value), - NewSubscriptionMinimumCompositePrice value => newSubscriptionMinimumComposite(value), - SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value => percent(value), - SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value => eventOutput( - value - ), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePrice" - ), - }; - } - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionUnitPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionBulkPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionPackagePrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMatrixPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionThresholdTotalAmountPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredPackagePrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredWithMinimumPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedTieredPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredPackageWithMinimumPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionPackageWithAllocationPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionUnitWithPercentPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMatrixWithAllocationPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionUnitWithProrationPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedAllocationPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionBulkWithProrationPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedWithProratedMinimumPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedWithMeteredMinimumPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMatrixWithDisplayNamePrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedTieredPackagePrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMaxGroupTieredPackagePrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionScalableMatrixWithUnitPricingPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionScalableMatrixWithTieredPricingPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionCumulativeGroupedBulkPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMinimumCompositePrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value - ) => new(value); - - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() - { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePrice" - ); - } - this.Switch( - (newSubscriptionUnit) => newSubscriptionUnit.Validate(), - (newSubscriptionTiered) => newSubscriptionTiered.Validate(), - (newSubscriptionBulk) => newSubscriptionBulk.Validate(), - (bulkWithFilters) => bulkWithFilters.Validate(), - (newSubscriptionPackage) => newSubscriptionPackage.Validate(), - (newSubscriptionMatrix) => newSubscriptionMatrix.Validate(), - (newSubscriptionThresholdTotalAmount) => newSubscriptionThresholdTotalAmount.Validate(), - (newSubscriptionTieredPackage) => newSubscriptionTieredPackage.Validate(), - (newSubscriptionTieredWithMinimum) => newSubscriptionTieredWithMinimum.Validate(), - (newSubscriptionGroupedTiered) => newSubscriptionGroupedTiered.Validate(), - (newSubscriptionTieredPackageWithMinimum) => - newSubscriptionTieredPackageWithMinimum.Validate(), - (newSubscriptionPackageWithAllocation) => - newSubscriptionPackageWithAllocation.Validate(), - (newSubscriptionUnitWithPercent) => newSubscriptionUnitWithPercent.Validate(), - (newSubscriptionMatrixWithAllocation) => newSubscriptionMatrixWithAllocation.Validate(), - (tieredWithProration) => tieredWithProration.Validate(), - (newSubscriptionUnitWithProration) => newSubscriptionUnitWithProration.Validate(), - (newSubscriptionGroupedAllocation) => newSubscriptionGroupedAllocation.Validate(), - (newSubscriptionBulkWithProration) => newSubscriptionBulkWithProration.Validate(), - (newSubscriptionGroupedWithProratedMinimum) => - newSubscriptionGroupedWithProratedMinimum.Validate(), - (newSubscriptionGroupedWithMeteredMinimum) => - newSubscriptionGroupedWithMeteredMinimum.Validate(), - (groupedWithMinMaxThresholds) => groupedWithMinMaxThresholds.Validate(), - (newSubscriptionMatrixWithDisplayName) => - newSubscriptionMatrixWithDisplayName.Validate(), - (newSubscriptionGroupedTieredPackage) => newSubscriptionGroupedTieredPackage.Validate(), - (newSubscriptionMaxGroupTieredPackage) => - newSubscriptionMaxGroupTieredPackage.Validate(), - (newSubscriptionScalableMatrixWithUnitPricing) => - newSubscriptionScalableMatrixWithUnitPricing.Validate(), - (newSubscriptionScalableMatrixWithTieredPricing) => - newSubscriptionScalableMatrixWithTieredPricing.Validate(), - (newSubscriptionCumulativeGroupedBulk) => - newSubscriptionCumulativeGroupedBulk.Validate(), - (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), - (newSubscriptionMinimumComposite) => newSubscriptionMinimumComposite.Validate(), - (percent) => percent.Validate(), - (eventOutput) => eventOutput.Validate() - ); - } - - public virtual bool Equals(SubscriptionSchedulePlanChangeParamsReplacePricePrice? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } - - public override int GetHashCode() - { - return 0; - } - - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceConverter - : JsonConverter -{ - public override SubscriptionSchedulePlanChangeParamsReplacePricePrice? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - string? modelType; - try - { - modelType = element.GetProperty("model_type").GetString(); - } - catch - { - modelType = null; - } - - switch (modelType) - { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "bulk": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "bulk_with_filters": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "package": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "matrix": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "threshold_total_amount": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_package": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_with_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_tiered": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_package_with_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "package_with_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "unit_with_percent": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "matrix_with_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_with_proration": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "unit_with_proration": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "bulk_with_proration": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_prorated_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_metered_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_min_max_thresholds": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "matrix_with_display_name": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_tiered_package": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "max_group_tiered_package": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "scalable_matrix_with_unit_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "scalable_matrix_with_tiered_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "cumulative_grouped_bulk": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "cumulative_grouped_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum_composite": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "percent": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "event_output": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new SubscriptionSchedulePlanChangeParamsReplacePricePrice(element); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePrice? value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value?.Json, options); - } -} - -[JsonConverter( - typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters, - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersFromRaw - >) -)] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters - : JsonModel -{ - /// - /// Configuration for bulk_with_filters pricing - /// - public required SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "bulk_with_filters_config" - ); - } - init { this._rawData.Set("bulk_with_filters_config", value); } - } - - /// - /// The cadence to bill for this price on. - /// - public required ApiEnum< - string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence - > Cadence - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum< - string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence - > - >("cadence"); - } - init { this._rawData.Set("cadence", value); } - } - - /// - /// The id of the item the price will be associated with. - /// - public required string ItemID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); - } - init { this._rawData.Set("item_id", value); } - } - - /// - /// The pricing model type - /// - public JsonElement ModelType - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); - } - init { this._rawData.Set("model_type", value); } - } - - /// - /// The name of the price. - /// - public required string Name - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } - } - - /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. - /// - public string? BillableMetricID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); - } - init { this._rawData.Set("billable_metric_id", value); } - } - - /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. - /// - public bool? BilledInAdvance - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); - } - init { this._rawData.Set("billed_in_advance", value); } - } - - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } - } - - /// - /// The per unit conversion rate of the price currency to the invoicing currency. - /// - public double? ConversionRate - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); - } - init { this._rawData.Set("conversion_rate", value); } - } - - /// - /// The configuration for the rate of the price currency to the invoicing currency. - /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", value); } - } - - /// - /// An ISO 4217 currency string, or custom pricing unit identifier, in which - /// this price is billed. - /// - public string? Currency - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("currency"); - } - init { this._rawData.Set("currency", value); } - } - - /// - /// For dimensional price: specifies a price group and dimension values - /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } - } - - /// - /// An alias for the price. - /// - public string? ExternalPriceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } - } - - /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. - /// - public double? FixedPriceQuantity - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } - } - - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", value); } - } - - /// - /// Within each billing cycle, specifies the cadence at which invoices are produced. - /// If unspecified, a single invoice is produced per billing cycle. - /// - public NewBillingCycleConfiguration? InvoicingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); - } - init { this._rawData.Set("invoicing_cycle_configuration", value); } - } - - /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared - /// by setting `metadata` to `null`. - /// - public IReadOnlyDictionary? Metadata - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) - ); - } - } - - /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. - /// - public string? ReferenceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("reference_id"); - } - init { this._rawData.Set("reference_id", value); } - } - - /// - public override void Validate() - { - this.BulkWithFiltersConfig.Validate(); - this.Cadence.Validate(); - _ = this.ItemID; - if ( - !JsonElement.DeepEquals( - this.ModelType, - JsonSerializer.SerializeToElement("bulk_with_filters") - ) - ) - { - throw new OrbInvalidDataException("Invalid value given for constant"); - } - _ = this.Name; - _ = this.BillableMetricID; - _ = this.BilledInAdvance; - this.BillingCycleConfiguration?.Validate(); - _ = this.ConversionRate; - this.ConversionRateConfig?.Validate(); - _ = this.Currency; - this.DimensionalPriceConfiguration?.Validate(); - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.InvoiceGroupingKey; - this.InvoicingCycleConfiguration?.Validate(); - _ = this.Metadata; - _ = this.ReferenceID; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters() - { - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters( - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters - ) - : base(subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters) { } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersFromRaw - : IFromRawJson -{ - /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters.FromRawUnchecked( - rawData - ); -} - -/// -/// Configuration for bulk_with_filters pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw - >) -)] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - : JsonModel -{ - /// - /// Property filters to apply (all must match) - /// - public required IReadOnlyList Filters - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("filters"); - } - init - { - this._rawData.Set< - ImmutableArray - >("filters", ImmutableArray.ToImmutableArray(value)); - } - } - - /// - /// Bulk tiers for rating based on total usage volume - /// - public required IReadOnlyList Tiers - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); - } - init - { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); - } - } - - /// - public override void Validate() - { - foreach (var item in this.Filters) - { - item.Validate(); - } - foreach (var item in this.Tiers) - { - item.Validate(); - } - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() - { } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - ) - : base( - subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - ) { } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw - : IFromRawJson -{ - /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked( - rawData - ); -} - -/// -/// Configuration for a single property filter -/// -[JsonConverter( - typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter, - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw - >) -)] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - : JsonModel -{ - /// - /// Event property key to filter on - /// - public required string PropertyKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_key"); - } - init { this._rawData.Set("property_key", value); } - } - - /// - /// Event property value to match - /// - public required string PropertyValue - { - get + var element = JsonSerializer.Deserialize(ref reader, options); + string? modelType; + try { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_value"); + modelType = element.GetProperty("model_type").GetString(); } - init { this._rawData.Set("property_value", value); } - } - - /// - public override void Validate() - { - _ = this.PropertyKey; - _ = this.PropertyValue; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() - { } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - ) - : base( - subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - ) { } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw - : IFromRawJson -{ - /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked( - rawData - ); -} - -/// -/// Configuration for a single bulk pricing tier -/// -[JsonConverter( - typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier, - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw - >) -)] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - : JsonModel -{ - /// - /// Amount per unit - /// - public required string UnitAmount - { - get + catch { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + modelType = null; } - init { this._rawData.Set("unit_amount", value); } - } - /// - /// The lower bound for this tier - /// - public string? TierLowerBound - { - get + switch (modelType) { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("tier_lower_bound"); - } - init { this._rawData.Set("tier_lower_bound", value); } - } - - /// - public override void Validate() - { - _ = this.UnitAmount; - _ = this.TierLowerBound; - } + case "unit": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() - { } + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - ) - : base( - subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - ) { } + return new(element); + } + case "bulk": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } + return new(element); + } + case "bulk_with_filters": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 + return new(element); + } + case "package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } + return new(element); + } + case "matrix": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - string unitAmount - ) - : this() - { - this.UnitAmount = unitAmount; - } -} + return new(element); + } + case "threshold_total_amount": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw - : IFromRawJson -{ - /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked( - rawData - ); -} + return new(element); + } + case "tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -/// -/// The cadence to bill for this price on. -/// -[JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadenceConverter) -)] -public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} + return new(element); + } + case "tiered_with_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadenceConverter - : JsonConverter -{ - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, - "semi_annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.SemiAnnual, - "monthly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Monthly, - "quarterly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Quarterly, - "one_time" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.OneTime, - "custom" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Custom, - _ => (SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence)(-1), - }; - } + return new(element); + } + case "grouped_tiered": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public override void Write( - Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch + return new(element); + } + case "tiered_package_with_minimum": { - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual => - "annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.SemiAnnual => - "semi_annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Monthly => - "monthly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Quarterly => - "quarterly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.OneTime => - "one_time", - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Custom => - "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -[JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfigConverter) -)] -public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig - : ModelBase -{ - public object? Value { get; } = null; + return new(element); + } + case "package_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - JsonElement? _element = null; + return new(element); + } + case "unit_with_percent": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public JsonElement Json - { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } - } + return new(element); + } + case "matrix_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + return new(element); + } + case "tiered_with_proration": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + return new(element); + } + case "unit_with_proration": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( - JsonElement element - ) - { - this._element = element; - } + return new(element); + } + case "grouped_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) - { - value = this.Value as SharedUnitConversionRateConfig; - return value != null; - } + return new(element); + } + case "bulk_with_proration": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) - { - value = this.Value as SharedTieredConversionRateConfig; - return value != null; - } + return new(element); + } + case "grouped_with_prorated_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action unit, - System::Action tiered - ) - { - switch (this.Value) - { - case SharedUnitConversionRateConfig value: - unit(value); - break; - case SharedTieredConversionRateConfig value: - tiered(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig" - ); - } - } + return new(element); + } + case "grouped_with_metered_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func unit, - System::Func tiered - ) - { - return this.Value switch - { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig" - ), - }; - } + return new(element); + } + case "grouped_with_min_max_thresholds": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); + return new(element); + } + case "matrix_with_display_name": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); + return new(element); + } + case "grouped_tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() - { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig" - ); - } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); - } + return new(element); + } + case "max_group_tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + return new(element); + } + case "scalable_matrix_with_unit_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public override int GetHashCode() - { - return 0; - } + return new(element); + } + case "scalable_matrix_with_tiered_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} + return new(element); + } + case "cumulative_grouped_bulk": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } + + return new(element); + } + case "cumulative_grouped_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfigConverter - : JsonConverter -{ - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; - try - { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); - } - catch - { - conversionRateType = null; - } + return new(element); + } + case "minimum_composite": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - switch (conversionRateType) - { - case "unit": + return new(element); + } + case "percent": { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -15559,14 +13593,15 @@ JsonSerializerOptions options return new(element); } - case "tiered": + case "event_output": { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -15583,38 +13618,51 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( - element - ); + return new SubscriptionSchedulePlanChangeParamsReplacePricePrice(element); } } } public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePrice? value, JsonSerializerOptions options ) { - JsonSerializer.Serialize(writer, value.Json, options); + JsonSerializer.Serialize(writer, value?.Json, options); } } [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters, + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters : JsonModel { + /// + /// Configuration for bulk_with_filters pricing + /// + public required SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "bulk_with_filters_config" + ); + } + init { this._rawData.Set("bulk_with_filters_config", value); } + } + /// /// The cadence to bill for this price on. /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence > Cadence { get @@ -15623,7 +13671,7 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence > >("cadence"); } @@ -15669,21 +13717,6 @@ public required string Name init { this._rawData.Set("name", value); } } - /// - /// Configuration for tiered_with_proration pricing - /// - public required SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig TieredWithProrationConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "tiered_with_proration_config" - ); - } - init { this._rawData.Set("tiered_with_proration_config", value); } - } - /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -15743,12 +13776,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig? ConversionRateConfig + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -15877,19 +13910,19 @@ public string? ReferenceID /// public override void Validate() { + this.BulkWithFiltersConfig.Validate(); this.Cadence.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("tiered_with_proration") + JsonSerializer.SerializeToElement("bulk_with_filters") ) ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.TieredWithProrationConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -15905,28 +13938,28 @@ public override void Validate() _ = this.ReferenceID; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration() + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration( - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters ) - : base(subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration) { } + : base(subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters) { } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters( FrozenDictionary rawData ) { @@ -15934,8 +13967,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15943,147 +13976,187 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters.FromRawUnchecked( rawData ); } /// -/// The cadence to bill for this price on. +/// Configuration for bulk_with_filters pricing /// [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadenceConverter) + typeof(JsonModelConverter< + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + >) )] -public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + : JsonModel { - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} + /// + /// Property filters to apply (all must match) + /// + public required IReadOnlyList Filters + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("filters"); + } + init + { + this._rawData.Set< + ImmutableArray + >("filters", ImmutableArray.ToImmutableArray(value)); + } + } -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadenceConverter - : JsonConverter -{ - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options + /// + /// Bulk tiers for rating based on total usage volume + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + public override void Validate() + { + foreach (var item in this.Filters) + { + item.Validate(); + } + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() + { } + + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + ) + : base( + subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + ) { } + + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + FrozenDictionary rawData ) { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, - "semi_annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.SemiAnnual, - "monthly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Monthly, - "quarterly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Quarterly, - "one_time" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.OneTime, - "custom" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Custom, - _ => (SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence)( - -1 - ), - }; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public override void Write( - Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence value, - JsonSerializerOptions options + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData ) { - JsonSerializer.Serialize( - writer, - value switch - { - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual => - "annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.SemiAnnual => - "semi_annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Monthly => - "monthly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Quarterly => - "quarterly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.OneTime => - "one_time", - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Custom => - "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } +class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + : IFromRawJson +{ + /// + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked( + rawData + ); +} + /// -/// Configuration for tiered_with_proration pricing +/// Configuration for a single property filter /// [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter, + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter : JsonModel { /// - /// Tiers for rating based on total usage quantities into the specified tier - /// with proration + /// Event property key to filter on /// - public required IReadOnlyList Tiers + public required string PropertyKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + return this._rawData.GetNotNullClass("property_key"); } - init + init { this._rawData.Set("property_key", value); } + } + + /// + /// Event property value to match + /// + public required string PropertyValue + { + get { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("property_value"); } + init { this._rawData.Set("property_value", value); } } /// public override void Validate() { - foreach (var item in this.Tiers) - { - item.Validate(); - } + _ = this.PropertyKey; + _ = this.PropertyValue; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig() + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig( - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter ) : base( - subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig + subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter ) { } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( IReadOnlyDictionary rawData ) { @@ -16092,7 +14165,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( FrozenDictionary rawData ) { @@ -16100,92 +14173,83 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig( - IReadOnlyList tiers - ) - : this() - { - this.Tiers = tiers; - } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked( rawData ); } /// -/// Configuration for a single tiered with proration tier +/// Configuration for a single bulk pricing tier /// [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier, + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier : JsonModel { /// - /// Inclusive tier starting value + /// Amount per unit /// - public required string TierLowerBound + public required string UnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("unit_amount"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("unit_amount", value); } } /// - /// Amount per unit + /// The lower bound for this tier /// - public required string UnitAmount + public string? TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNullableClass("tier_lower_bound"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("tier_lower_bound", value); } } /// public override void Validate() { - _ = this.TierLowerBound; _ = this.UnitAmount; + _ = this.TierLowerBound; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier ) : base( - subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier ) { } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( IReadOnlyDictionary rawData ) { @@ -16194,7 +14258,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( FrozenDictionary rawData ) { @@ -16202,31 +14266,114 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } + + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + string unitAmount + ) + : this() + { + this.UnitAmount = unitAmount; + } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked( rawData ); } +/// +/// The cadence to bill for this price on. +/// +[JsonConverter( + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadenceConverter) +)] +public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadenceConverter + : JsonConverter +{ + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, + "semi_annual" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.SemiAnnual, + "monthly" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Monthly, + "quarterly" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Quarterly, + "one_time" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.OneTime, + "custom" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Custom, + _ => (SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual => + "annual", + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.SemiAnnual => + "semi_annual", + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Monthly => + "monthly", + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Quarterly => + "quarterly", + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.OneTime => + "one_time", + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Custom => + "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfigConverter) + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfigConverter) )] -public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig +public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -16244,7 +14391,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16253,7 +14400,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationC this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16262,7 +14409,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationC this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( JsonElement element ) { @@ -16346,7 +14493,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig" ); } } @@ -16382,16 +14529,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -16410,14 +14557,14 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig? other + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig? other ) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); @@ -16432,10 +14579,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfigConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16500,7 +14647,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( element ); } @@ -16509,7 +14656,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value, JsonSerializerOptions options ) { @@ -16519,11 +14666,11 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration : JsonModel { /// @@ -16531,7 +14678,7 @@ public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePrice /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > Cadence { get @@ -16540,28 +14687,13 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > >("cadence"); } init { this._rawData.Set("cadence", value); } } - /// - /// Configuration for grouped_with_min_max_thresholds pricing - /// - public required SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_with_min_max_thresholds_config" - ); - } - init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } - } - /// /// The id of the item the price will be associated with. /// @@ -16601,6 +14733,21 @@ public required string Name init { this._rawData.Set("name", value); } } + /// + /// Configuration for tiered_with_proration pricing + /// + public required SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig TieredWithProrationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "tiered_with_proration_config" + ); + } + init { this._rawData.Set("tiered_with_proration_config", value); } + } + /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -16660,12 +14807,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -16795,18 +14942,18 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.GroupedWithMinMaxThresholdsConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + JsonSerializer.SerializeToElement("tiered_with_proration") ) ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; + this.TieredWithProrationConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -16822,28 +14969,28 @@ public override void Validate() _ = this.ReferenceID; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds() + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds( - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration ) - : base(subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds) { } + : base(subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration) { } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration( FrozenDictionary rawData ) { @@ -16851,8 +14998,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16860,14 +15007,14 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration.FromRawUnchecked( rawData ); } @@ -16876,9 +15023,9 @@ IReadOnlyDictionary rawData /// The cadence to bill for this price on. /// [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter) + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadenceConverter) )] -public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence +public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence { Annual, SemiAnnual, @@ -16888,10 +15035,10 @@ public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinM Custom, } -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadenceConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16900,139 +15047,209 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, "semi_annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.SemiAnnual, "monthly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Monthly, "quarterly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Quarterly, "one_time" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.OneTime, "custom" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom, - _ => - (SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence)( - -1 - ), + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Custom, + _ => (SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence)( + -1 + ), }; } - public override void Write( - Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence value, - JsonSerializerOptions options + public override void Write( + Utf8JsonWriter writer, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual => + "annual", + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.SemiAnnual => + "semi_annual", + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Monthly => + "monthly", + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Quarterly => + "quarterly", + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.OneTime => + "one_time", + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Custom => + "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for tiered_with_proration pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw + >) +)] +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig + : JsonModel +{ + /// + /// Tiers for rating based on total usage quantities into the specified tier + /// with proration + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + public override void Validate() + { + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig() + { } + + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig + ) + : base( + subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig + ) { } + + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyList tiers ) + : this() { - JsonSerializer.Serialize( - writer, - value switch - { - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual => - "annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => - "semi_annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly => - "monthly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly => - "quarterly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime => - "one_time", - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom => - "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); + this.Tiers = tiers; } } +class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw + : IFromRawJson +{ + /// + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked( + rawData + ); +} + /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for a single tiered with proration tier /// [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier : JsonModel { /// - /// The event property used to group before applying thresholds - /// - public required string GroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); - } - init { this._rawData.Set("grouping_key", value); } - } - - /// - /// The maximum amount to charge each group - /// - public required string MaximumCharge - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); - } - init { this._rawData.Set("maximum_charge", value); } - } - - /// - /// The minimum amount to charge each group, regardless of usage + /// Inclusive tier starting value /// - public required string MinimumCharge + public required string TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullClass("tier_lower_bound"); } - init { this._rawData.Set("minimum_charge", value); } + init { this._rawData.Set("tier_lower_bound", value); } } /// - /// The base price charged per group + /// Amount per unit /// - public required string PerUnitRate + public required string UnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("per_unit_rate"); + return this._rawData.GetNotNullClass("unit_amount"); } - init { this._rawData.Set("per_unit_rate", value); } + init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + _ = this.TierLowerBound; + _ = this.UnitAmount; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() { } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier ) : base( - subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier ) { } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( IReadOnlyDictionary rawData ) { @@ -17041,7 +15258,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( FrozenDictionary rawData ) { @@ -17049,8 +15266,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17058,22 +15275,22 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked( rawData ); } [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter) + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfigConverter) )] -public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig +public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -17091,7 +15308,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17100,7 +15317,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThr this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -17109,7 +15326,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThr this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( JsonElement element ) { @@ -17193,7 +15410,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig" ); } } @@ -17229,16 +15446,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -17257,14 +15474,14 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig? other ) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); @@ -17279,10 +15496,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17347,7 +15564,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( element ); } @@ -17356,7 +15573,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -17366,11 +15583,11 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds : JsonModel { /// @@ -17378,7 +15595,7 @@ public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePrice /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > Cadence { get @@ -17387,7 +15604,7 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > >("cadence"); } @@ -17395,18 +15612,18 @@ public required ApiEnum< } /// - /// Configuration for cumulative_grouped_allocation pricing + /// Configuration for grouped_with_min_max_thresholds pricing /// - public required SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "cumulative_grouped_allocation_config" + return this._rawData.GetNotNullClass( + "grouped_with_min_max_thresholds_config" ); } - init { this._rawData.Set("cumulative_grouped_allocation_config", value); } + init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } } /// @@ -17507,12 +15724,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -17642,12 +15859,12 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.CumulativeGroupedAllocationConfig.Validate(); + this.GroupedWithMinMaxThresholdsConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") ) ) { @@ -17669,28 +15886,28 @@ public override void Validate() _ = this.ReferenceID; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation() + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation( - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds ) - : base(subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation) { } + : base(subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds) { } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds( FrozenDictionary rawData ) { @@ -17698,8 +15915,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17707,14 +15924,14 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked( rawData ); } @@ -17723,9 +15940,9 @@ IReadOnlyDictionary rawData /// The cadence to bill for this price on. /// [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadenceConverter) + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter) )] -public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence +public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence { Annual, SemiAnnual, @@ -17735,10 +15952,10 @@ public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroup Custom, } -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence Read( + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17747,19 +15964,19 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, "semi_annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual, "monthly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Monthly, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly, "quarterly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly, "one_time" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.OneTime, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime, "custom" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Custom, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom, _ => - (SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence)( + (SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence)( -1 ), }; @@ -17767,7 +15984,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -17775,17 +15992,17 @@ JsonSerializerOptions options writer, value switch { - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual => + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual => "annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual => + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Monthly => + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly => "monthly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly => + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.OneTime => + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime => "one_time", - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Custom => + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -17797,89 +16014,89 @@ JsonSerializerOptions options } /// -/// Configuration for cumulative_grouped_allocation pricing +/// Configuration for grouped_with_min_max_thresholds pricing /// [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig : JsonModel { /// - /// The overall allocation across all groups + /// The event property used to group before applying thresholds /// - public required string CumulativeAllocation + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("cumulative_allocation"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("cumulative_allocation", value); } + init { this._rawData.Set("grouping_key", value); } } /// - /// The allocation per individual group + /// The maximum amount to charge each group /// - public required string GroupAllocation + public required string MaximumCharge { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group_allocation"); + return this._rawData.GetNotNullClass("maximum_charge"); } - init { this._rawData.Set("group_allocation", value); } + init { this._rawData.Set("maximum_charge", value); } } /// - /// The event property used to group usage before applying allocations + /// The minimum amount to charge each group, regardless of usage /// - public required string GroupingKey + public required string MinimumCharge { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("minimum_charge"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("minimum_charge", value); } } /// - /// The amount to charge for each unit outside of the allocation + /// The base price charged per group /// - public required string UnitAmount + public required string PerUnitRate { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullClass("per_unit_rate"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("per_unit_rate", value); } } /// public override void Validate() { - _ = this.CumulativeAllocation; - _ = this.GroupAllocation; _ = this.GroupingKey; - _ = this.UnitAmount; + _ = this.MaximumCharge; + _ = this.MinimumCharge; + _ = this.PerUnitRate; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) : base( - subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) { } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData ) { @@ -17888,7 +16105,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -17896,8 +16113,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17905,22 +16122,22 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( rawData ); } [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter) + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter) )] -public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig +public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -17938,7 +16155,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17947,7 +16164,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAll this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -17956,7 +16173,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAll this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( JsonElement element ) { @@ -18040,7 +16257,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } } @@ -18076,16 +16293,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -18104,14 +16321,14 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? other + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other ) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); @@ -18126,10 +16343,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -18194,7 +16411,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( element ); } @@ -18203,7 +16420,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -18213,56 +16430,60 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum, - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum : JsonModel +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + : JsonModel { /// /// The cadence to bill for this price on. /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum< + string, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + > >("cadence"); } init { this._rawData.Set("cadence", value); } } /// - /// The id of the item the price will be associated with. + /// Configuration for cumulative_grouped_allocation pricing /// - public required string ItemID + public required SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass( + "cumulative_grouped_allocation_config" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("cumulative_grouped_allocation_config", value); } } /// - /// Configuration for minimum pricing + /// The id of the item the price will be associated with. /// - public required SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig MinimumConfig + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" - ); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("minimum_config", value); } + init { this._rawData.Set("item_id", value); } } /// @@ -18350,12 +16571,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig? ConversionRateConfig + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -18485,9 +16706,14 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); + this.CumulativeGroupedAllocationConfig.Validate(); _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -18507,28 +16733,28 @@ public override void Validate() _ = this.ReferenceID; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum() + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum( - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum subscriptionSchedulePlanChangeParamsReplacePricePriceMinimum + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation ) - : base(subscriptionSchedulePlanChangeParamsReplacePricePriceMinimum) { } + : base(subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation) { } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation( FrozenDictionary rawData ) { @@ -18536,8 +16762,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -18545,22 +16771,25 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum.FromRawUnchecked(rawData); + ) => + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked( + rawData + ); } /// /// The cadence to bill for this price on. /// [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadenceConverter) + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadenceConverter) )] -public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence +public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence { Annual, SemiAnnual, @@ -18570,10 +16799,10 @@ public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence Custom, } -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadenceConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadenceConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence Read( + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -18581,23 +16810,28 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual, + "annual" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, "semi_annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.SemiAnnual, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual, "monthly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Monthly, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Monthly, "quarterly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Quarterly, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly, "one_time" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.OneTime, - "custom" => SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Custom, - _ => (SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence)(-1), + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.OneTime, + "custom" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Custom, + _ => + (SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence)( + -1 + ), }; } public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -18605,17 +16839,17 @@ JsonSerializerOptions options writer, value switch { - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual => + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual => "annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.SemiAnnual => + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Monthly => + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Monthly => "monthly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Quarterly => + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly => "quarterly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.OneTime => + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.OneTime => "one_time", - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Custom => + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -18627,66 +16861,89 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for cumulative_grouped_allocation pricing /// [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig, - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfigFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig : JsonModel { /// - /// The minimum amount to apply + /// The overall allocation across all groups /// - public required string MinimumAmount + public required string CumulativeAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNotNullClass("cumulative_allocation"); } - init { this._rawData.Set("minimum_amount", value); } + init { this._rawData.Set("cumulative_allocation", value); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// The allocation per individual group /// - public bool? Prorated + public required string GroupAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); + return this._rawData.GetNotNullClass("group_allocation"); } - init + init { this._rawData.Set("group_allocation", value); } + } + + /// + /// The event property used to group usage before applying allocations + /// + public required string GroupingKey + { + get { - if (value == null) - { - return; - } + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } - this._rawData.Set("prorated", value); + /// + /// The amount to charge for each unit outside of the allocation + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); } + init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.MinimumAmount; - _ = this.Prorated; + _ = this.CumulativeAllocation; + _ = this.GroupAllocation; + _ = this.GroupingKey; + _ = this.UnitAmount; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig() { } + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() + { } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig( - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig subscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) - : base(subscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig) { } + : base( + subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + ) { } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( IReadOnlyDictionary rawData ) { @@ -18695,7 +16952,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( FrozenDictionary rawData ) { @@ -18703,40 +16960,31 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig( - string minimumAmount - ) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfigFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( rawData ); } [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfigConverter) + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter) )] -public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig +public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -18754,7 +17002,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -18763,7 +17011,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRat this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -18772,7 +17020,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRat this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( JsonElement element ) { @@ -18856,7 +17104,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ); } } @@ -18892,16 +17140,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -18920,14 +17168,14 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig? other + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? other ) { return other != null && JsonElement.DeepEquals(this.Json, other.Json); @@ -18942,10 +17190,10 @@ public override string ToString() => JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); } -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfigConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -19010,7 +17258,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( element ); } @@ -19019,7 +17267,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { diff --git a/src/Orb/Models/Subscriptions/SubscriptionTriggerPhaseParams.cs b/src/Orb/Models/Subscriptions/SubscriptionTriggerPhaseParams.cs index 5477bafa..9ae659d8 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionTriggerPhaseParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionTriggerPhaseParams.cs @@ -11,8 +11,12 @@ namespace Orb.Models.Subscriptions; /// /// Manually trigger a phase, effective the given date (or the current time, if not specified). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionTriggerPhaseParams : ParamsBase +public record class SubscriptionTriggerPhaseParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -53,6 +57,8 @@ public string? EffectiveDate public SubscriptionTriggerPhaseParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionTriggerPhaseParams( SubscriptionTriggerPhaseParams subscriptionTriggerPhaseParams ) @@ -62,6 +68,7 @@ SubscriptionTriggerPhaseParams subscriptionTriggerPhaseParams this._rawBodyData = new(subscriptionTriggerPhaseParams._rawBodyData); } +#pragma warning restore CS8618 public SubscriptionTriggerPhaseParams( IReadOnlyDictionary rawHeaderData, @@ -102,6 +109,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["SubscriptionID"] = this.SubscriptionID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionTriggerPhaseParams? other) + { + if (other == null) + { + return false; + } + return (this.SubscriptionID?.Equals(other.SubscriptionID) ?? other.SubscriptionID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -130,4 +161,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Subscriptions/SubscriptionUnscheduleCancellationParams.cs b/src/Orb/Models/Subscriptions/SubscriptionUnscheduleCancellationParams.cs index 0efc26fb..6f3300f9 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionUnscheduleCancellationParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionUnscheduleCancellationParams.cs @@ -14,13 +14,19 @@ namespace Orb.Models.Subscriptions; /// To be eligible, the subscription must currently be active and have a future /// cancellation. This operation will turn on auto-renew, ensuring that the subscription /// does not end at the currently scheduled cancellation time. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionUnscheduleCancellationParams : ParamsBase +public record class SubscriptionUnscheduleCancellationParams : ParamsBase { public string? SubscriptionID { get; init; } public SubscriptionUnscheduleCancellationParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionUnscheduleCancellationParams( SubscriptionUnscheduleCancellationParams subscriptionUnscheduleCancellationParams ) @@ -28,6 +34,7 @@ SubscriptionUnscheduleCancellationParams subscriptionUnscheduleCancellationParam { this.SubscriptionID = subscriptionUnscheduleCancellationParams.SubscriptionID; } +#pragma warning restore CS8618 public SubscriptionUnscheduleCancellationParams( IReadOnlyDictionary rawHeaderData, @@ -62,6 +69,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["SubscriptionID"] = this.SubscriptionID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionUnscheduleCancellationParams? other) + { + if (other == null) + { + return false; + } + return (this.SubscriptionID?.Equals(other.SubscriptionID) ?? other.SubscriptionID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -81,4 +110,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Subscriptions/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.cs b/src/Orb/Models/Subscriptions/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.cs index 3e356fe6..d6812252 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.cs @@ -14,8 +14,12 @@ namespace Orb.Models.Subscriptions; /// /// If there are no updates scheduled, a request validation error will be returned /// with a 400 status code. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionUnscheduleFixedFeeQuantityUpdatesParams : ParamsBase +public record class SubscriptionUnscheduleFixedFeeQuantityUpdatesParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -40,6 +44,8 @@ public required string PriceID public SubscriptionUnscheduleFixedFeeQuantityUpdatesParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionUnscheduleFixedFeeQuantityUpdatesParams( SubscriptionUnscheduleFixedFeeQuantityUpdatesParams subscriptionUnscheduleFixedFeeQuantityUpdatesParams ) @@ -49,6 +55,7 @@ SubscriptionUnscheduleFixedFeeQuantityUpdatesParams subscriptionUnscheduleFixedF this._rawBodyData = new(subscriptionUnscheduleFixedFeeQuantityUpdatesParams._rawBodyData); } +#pragma warning restore CS8618 public SubscriptionUnscheduleFixedFeeQuantityUpdatesParams( IReadOnlyDictionary rawHeaderData, @@ -89,6 +96,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["SubscriptionID"] = this.SubscriptionID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionUnscheduleFixedFeeQuantityUpdatesParams? other) + { + if (other == null) + { + return false; + } + return (this.SubscriptionID?.Equals(other.SubscriptionID) ?? other.SubscriptionID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -120,4 +151,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Subscriptions/SubscriptionUnschedulePendingPlanChangesParams.cs b/src/Orb/Models/Subscriptions/SubscriptionUnschedulePendingPlanChangesParams.cs index 7f50496a..f18b7278 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionUnschedulePendingPlanChangesParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionUnschedulePendingPlanChangesParams.cs @@ -11,13 +11,19 @@ namespace Orb.Models.Subscriptions; /// /// This endpoint can be used to unschedule any pending plan changes on an existing /// subscription. When called, all upcoming plan changes will be unscheduled. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionUnschedulePendingPlanChangesParams : ParamsBase +public record class SubscriptionUnschedulePendingPlanChangesParams : ParamsBase { public string? SubscriptionID { get; init; } public SubscriptionUnschedulePendingPlanChangesParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionUnschedulePendingPlanChangesParams( SubscriptionUnschedulePendingPlanChangesParams subscriptionUnschedulePendingPlanChangesParams ) @@ -25,6 +31,7 @@ SubscriptionUnschedulePendingPlanChangesParams subscriptionUnschedulePendingPlan { this.SubscriptionID = subscriptionUnschedulePendingPlanChangesParams.SubscriptionID; } +#pragma warning restore CS8618 public SubscriptionUnschedulePendingPlanChangesParams( IReadOnlyDictionary rawHeaderData, @@ -59,6 +66,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["SubscriptionID"] = this.SubscriptionID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionUnschedulePendingPlanChangesParams? other) + { + if (other == null) + { + return false; + } + return (this.SubscriptionID?.Equals(other.SubscriptionID) ?? other.SubscriptionID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -81,4 +110,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Subscriptions/SubscriptionUpdateFixedFeeQuantityParams.cs b/src/Orb/Models/Subscriptions/SubscriptionUpdateFixedFeeQuantityParams.cs index afd9dab9..beb63d10 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionUpdateFixedFeeQuantityParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionUpdateFixedFeeQuantityParams.cs @@ -24,8 +24,12 @@ namespace Orb.Models.Subscriptions; /// /// If the fee is an in-advance fixed fee, it will also issue an immediate /// invoice for the difference for the remainder of the billing period. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionUpdateFixedFeeQuantityParams : ParamsBase +public record class SubscriptionUpdateFixedFeeQuantityParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -115,6 +119,8 @@ public string? EffectiveDate public SubscriptionUpdateFixedFeeQuantityParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionUpdateFixedFeeQuantityParams( SubscriptionUpdateFixedFeeQuantityParams subscriptionUpdateFixedFeeQuantityParams ) @@ -124,6 +130,7 @@ SubscriptionUpdateFixedFeeQuantityParams subscriptionUpdateFixedFeeQuantityParam this._rawBodyData = new(subscriptionUpdateFixedFeeQuantityParams._rawBodyData); } +#pragma warning restore CS8618 public SubscriptionUpdateFixedFeeQuantityParams( IReadOnlyDictionary rawHeaderData, @@ -164,6 +171,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["SubscriptionID"] = this.SubscriptionID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionUpdateFixedFeeQuantityParams? other) + { + if (other == null) + { + return false; + } + return (this.SubscriptionID?.Equals(other.SubscriptionID) ?? other.SubscriptionID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -192,6 +223,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// diff --git a/src/Orb/Models/Subscriptions/SubscriptionUpdateParams.cs b/src/Orb/Models/Subscriptions/SubscriptionUpdateParams.cs index cebb442b..d40b9781 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionUpdateParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionUpdateParams.cs @@ -12,8 +12,12 @@ namespace Orb.Models.Subscriptions; /// /// This endpoint can be used to update the `metadata`, `net terms`, `auto_collection`, /// `invoicing_threshold`, and `default_invoice_memo` properties on a subscription. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionUpdateParams : ParamsBase +public record class SubscriptionUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -108,6 +112,8 @@ public long? NetTerms public SubscriptionUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionUpdateParams(SubscriptionUpdateParams subscriptionUpdateParams) : base(subscriptionUpdateParams) { @@ -115,6 +121,7 @@ public SubscriptionUpdateParams(SubscriptionUpdateParams subscriptionUpdateParam this._rawBodyData = new(subscriptionUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public SubscriptionUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -155,6 +162,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["SubscriptionID"] = this.SubscriptionID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionUpdateParams? other) + { + if (other == null) + { + return false; + } + return (this.SubscriptionID?.Equals(other.SubscriptionID) ?? other.SubscriptionID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -183,4 +214,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Subscriptions/SubscriptionUpdateTrialParams.cs b/src/Orb/Models/Subscriptions/SubscriptionUpdateTrialParams.cs index 2868ee9c..d455a557 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionUpdateTrialParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionUpdateTrialParams.cs @@ -30,8 +30,12 @@ namespace Orb.Models.Subscriptions; /// trial end date shift (so, e.g., if a plan change is scheduled or an add-on price /// was added, that change will be pushed back by the same amount of time the trial /// is extended). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionUpdateTrialParams : ParamsBase +public record class SubscriptionUpdateTrialParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -79,6 +83,8 @@ public bool? Shift public SubscriptionUpdateTrialParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionUpdateTrialParams( SubscriptionUpdateTrialParams subscriptionUpdateTrialParams ) @@ -88,6 +94,7 @@ SubscriptionUpdateTrialParams subscriptionUpdateTrialParams this._rawBodyData = new(subscriptionUpdateTrialParams._rawBodyData); } +#pragma warning restore CS8618 public SubscriptionUpdateTrialParams( IReadOnlyDictionary rawHeaderData, @@ -128,6 +135,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["SubscriptionID"] = this.SubscriptionID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionUpdateTrialParams? other) + { + if (other == null) + { + return false; + } + return (this.SubscriptionID?.Equals(other.SubscriptionID) ?? other.SubscriptionID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -156,6 +187,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// diff --git a/src/Orb/Models/TopLevel/TopLevelPingParams.cs b/src/Orb/Models/TopLevel/TopLevelPingParams.cs index 97a7b68b..b4314ad1 100644 --- a/src/Orb/Models/TopLevel/TopLevelPingParams.cs +++ b/src/Orb/Models/TopLevel/TopLevelPingParams.cs @@ -15,13 +15,20 @@ namespace Orb.Models.TopLevel; /// choice for connectors and integrations. /// /// This API does not have any side-effects or return any Orb resources. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TopLevelPingParams : ParamsBase +public record class TopLevelPingParams : ParamsBase { public TopLevelPingParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopLevelPingParams(TopLevelPingParams topLevelPingParams) : base(topLevelPingParams) { } +#pragma warning restore CS8618 public TopLevelPingParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TopLevelPingParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/ping") @@ -72,4 +99,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Orb.csproj b/src/Orb/Orb.csproj index 9722a9eb..f2cc47b8 100644 --- a/src/Orb/Orb.csproj +++ b/src/Orb/Orb.csproj @@ -3,7 +3,7 @@ Orb C# Orb - 0.1.0 + 0.2.0 The official .NET library for the Orb API. Library README.md diff --git a/src/Orb/Services/Coupons/ISubscriptionService.cs b/src/Orb/Services/Coupons/ISubscriptionService.cs index cbf3ddb5..a86ee0cc 100644 --- a/src/Orb/Services/Coupons/ISubscriptionService.cs +++ b/src/Orb/Services/Coupons/ISubscriptionService.cs @@ -17,16 +17,14 @@ public interface ISubscriptionService /// Returns a view of this service that provides access to raw HTTP responses /// for each method. /// - global::Orb.Services.Coupons.ISubscriptionServiceWithRawResponse WithRawResponse { get; } + ISubscriptionServiceWithRawResponse WithRawResponse { get; } /// /// Returns a view of this service with the given option modifications applied. /// /// The original service is not modified. /// - global::Orb.Services.Coupons.ISubscriptionService WithOptions( - Func modifier - ); + ISubscriptionService WithOptions(Func modifier); /// /// This endpoint returns a list of all subscriptions that have redeemed a given @@ -48,7 +46,7 @@ Task List( } /// -/// A view of that provides access to raw +/// A view of that provides access to raw /// HTTP responses for each method. /// public interface ISubscriptionServiceWithRawResponse @@ -58,13 +56,11 @@ public interface ISubscriptionServiceWithRawResponse /// /// The original service is not modified. /// - global::Orb.Services.Coupons.ISubscriptionServiceWithRawResponse WithOptions( - Func modifier - ); + ISubscriptionServiceWithRawResponse WithOptions(Func modifier); /// /// Returns a raw HTTP response for `get /coupons/{coupon_id}/subscriptions`, but is otherwise the - /// same as . + /// same as . /// Task> List( SubscriptionListParams parameters, diff --git a/src/Orb/Services/Coupons/SubscriptionService.cs b/src/Orb/Services/Coupons/SubscriptionService.cs index 6bfe328b..fe70b76d 100644 --- a/src/Orb/Services/Coupons/SubscriptionService.cs +++ b/src/Orb/Services/Coupons/SubscriptionService.cs @@ -10,12 +10,12 @@ namespace Orb.Services.Coupons; /// -public sealed class SubscriptionService : global::Orb.Services.Coupons.ISubscriptionService +public sealed class SubscriptionService : ISubscriptionService { - readonly Lazy _withRawResponse; + readonly Lazy _withRawResponse; /// - public global::Orb.Services.Coupons.ISubscriptionServiceWithRawResponse WithRawResponse + public ISubscriptionServiceWithRawResponse WithRawResponse { get { return _withRawResponse.Value; } } @@ -23,13 +23,9 @@ public sealed class SubscriptionService : global::Orb.Services.Coupons.ISubscrip readonly IOrbClient _client; /// - public global::Orb.Services.Coupons.ISubscriptionService WithOptions( - Func modifier - ) + public ISubscriptionService WithOptions(Func modifier) { - return new global::Orb.Services.Coupons.SubscriptionService( - this._client.WithOptions(modifier) - ); + return new SubscriptionService(this._client.WithOptions(modifier)); } public SubscriptionService(IOrbClient client) @@ -37,9 +33,7 @@ public SubscriptionService(IOrbClient client) _client = client; _withRawResponse = new(() => - new global::Orb.Services.Coupons.SubscriptionServiceWithRawResponse( - client.WithRawResponse - ) + new SubscriptionServiceWithRawResponse(client.WithRawResponse) ); } @@ -69,19 +63,16 @@ public Task List( } /// -public sealed class SubscriptionServiceWithRawResponse - : global::Orb.Services.Coupons.ISubscriptionServiceWithRawResponse +public sealed class SubscriptionServiceWithRawResponse : ISubscriptionServiceWithRawResponse { readonly IOrbClientWithRawResponse _client; /// - public global::Orb.Services.Coupons.ISubscriptionServiceWithRawResponse WithOptions( + public ISubscriptionServiceWithRawResponse WithOptions( Func modifier ) { - return new global::Orb.Services.Coupons.SubscriptionServiceWithRawResponse( - this._client.WithOptions(modifier) - ); + return new SubscriptionServiceWithRawResponse(this._client.WithOptions(modifier)); } public SubscriptionServiceWithRawResponse(IOrbClientWithRawResponse client) diff --git a/src/Orb/Services/Customers/Credits/ILedgerService.cs b/src/Orb/Services/Customers/Credits/ILedgerService.cs index 11adc9de..bc36776d 100644 --- a/src/Orb/Services/Customers/Credits/ILedgerService.cs +++ b/src/Orb/Services/Customers/Credits/ILedgerService.cs @@ -49,10 +49,8 @@ public interface ILedgerService /// As usage for a customer is reported into Orb, credits may be deducted /// according to the customer's plan configuration. An automated deduction of /// this type will result in a ledger entry, also with a starting and ending balance. - /// In order to provide better tracing capabilities for automatic deductions, - /// Orb always associates each automatic deduction with the `event_id` at the - /// time of ingestion, used to pinpoint _why_ credit deduction took place and - /// to ensure that credits are never deducted without an associated usage event. + /// Each day's usage for a particular price, invoice, and block will be grouped + /// into a single entry. /// /// By default, Orb uses an algorithm that automatically deducts from the /// *soonest expiring credit block* first in order to ensure that all credits @@ -328,10 +326,8 @@ Task CreateEntryByExternalID( /// As usage for a customer is reported into Orb, credits may be deducted /// according to the customer's plan configuration. An automated deduction of /// this type will result in a ledger entry, also with a starting and ending balance. - /// In order to provide better tracing capabilities for automatic deductions, - /// Orb always associates each automatic deduction with the `event_id` at the - /// time of ingestion, used to pinpoint _why_ credit deduction took place and - /// to ensure that credits are never deducted without an associated usage event. + /// Each day's usage for a particular price, invoice, and block will be grouped + /// into a single entry. /// /// By default, Orb uses an algorithm that automatically deducts from the /// *soonest expiring credit block* first in order to ensure that all credits